You should be able to find a good used D7000 for under a grand easy.
16 megapixels and handles like a dream. One of my favorites. I just sold mine. It’s DX too, so it will use all the lenses your D40 does. You’ll have a hard time stepping up to FX in that price range, but you could get lucky.
My first Nikon was an F3 HP. I miss it it, but not messing with film. there are still some hold outs that prefer film, though.
A good site for camera reviews and general photo advice is Ken Rockwell.com
Good luck.
I am looking up the D7000 - this thing shoots MOVIES? Does the mirror stay up when it is shooting? Gee whiz I got old quick. Okay... Just inside my range. Thanks.