I would put a new sandbed in the new tank, but seed it with a cup or two of sand from the old tank. This should give you the best of bacterial starter cultures without unleashing a lot detritus from the old sandbed.
Then, you can do cascading water changes from the old tank to the new - ie, take 10 gallons from old tank to new tank, add 10 gallons of fresh water to the old tank. You can slowly transition a full tank of seasoned water from one tank to the other this way. Once both tanks have the same water parameter you can easily move things between them.
It also might help to have a brute or other temporary container you can fill with tank water, a heater, and a power head. That will give you a holding tank if you have complex rock structure to take apart (ie: move the rocks out top-down, into the holding tank, until you're at the base and can move the base into the new tank, then re-build your full rock structure).
If you can have both tanks up and running, this kind of slow, deliberate process is a lot more safe and stable. If you're planning to put the 40 gallon in the same location as the old tank, you may have to do everything more quickly and I'd recommend a larger holding container.