What do you mean by "upgrade"? Are you taken in by the wrong-headed ad hype that says you need more-more-more pixels? -You don't, unless you're printing hughmungous-sized posters. -Most honest reviewers will tell you you'll almost always get less 'noise' with a good 6MP DSLR (such as the D40!) than with 10 or 12MPs! For instance, many reviewers will tell you that the 6MP D40 is a better camera than the 10MP D40X! The D40's noise level is rated good right up to 800 and acceptable at 1600, while the D40X, BECAUSE of it's more MPs, is rated good only up thru ISO 400!
So, do you perhaps want better ability in low light? More clarity and sharpness? Then get a non-zoom, prime lens such as the Nikkor f1.8 35mm lens ($200). It's fantastic, is a great match with the D40, and can teach you more about photography than only using a zoom ever will!
Or maybe you want stronger zoom capability? -Again, it's the lens!
People will probably tell you that the new D90 is better than the D40. Maybe, -maybe you can shoot better in lower light with it (again tho, only with a good lens?), but it's also a lot more complicated (and bigger and heavier) than the D40, and I wouldn't buy one until I was sure I'd mastered, to my own satisfaction, all that the very capable little D40 had to offer!
Thinking of the D3000? Forget it! More MPs, true, but it's reviews regarding it's low light ability are terrible, and IMO it would actually be a step DOWN from your D40! Same with the D5000. I would only buy a D5000 if I absolutely needed video capability and a fold out rear LCD screen. Other than that? -Keep your D40!
Nikon got a lot right with the little D40, and many once wary photographers (because of it's smaller size) are beginning to appreciate that now! So unless you're willing to go for the big $$ and spring for the fantastic D300s or D700 (both bigger and heavier) DSLRs, I would forgo the D90-D3000-D5000 trip and stick with the capable D40 for a while...
But new and better lenses? IMO that's always fun, creates interesting improvement, and then they can always be transferred to another Nikon DSLR later on too! (Also you can always get great used or refurbished ones for a more reasonable price...)