Hello Peterlee blue, and welcome to the friendly Camera Labs forum!
To enjoy your stay here please have a look at the house-rules
It's always good to concentrate on lenses and not overvalue bodies. But the question is: how long will a D40x body bear with you. The D40x was certainly a competent little camera at its time but I really would suggest to go with the D5100. It has the same excellent sensor as the D7000 and that is what can last you for a very long time.
Thomas (beware: Nikon-fanboy and moderator!) My Lens Reviews
, My Pictures
, My Photography Blog