I love my Sony A200. Takes some great pics.
Id say its really up to you. the D40 is only 6.3MP, the A200 is 10.2 and has built in stabilization. Every lens is turned into a stabilization lens. Even old lenses from before image stabilization came about...
but sabbath999 is right, you can buy an inexpensive tamron, and and they take GREAT pictures. I have one from my canon film camera days (yep i switched to Sony, canon didnt have what I wanted under 1000) I was going to stick with Canon, but I got a A200 with kit lens, a 70-200mm f/4.5-6 lens, a NICE sony alpha bag, and a spare battery for $700 back in june.
Depends what you want. Go see if you can test out the A200. Maybe you will like it more? I went from a Canon A2 (full size camera body) to my A200. canon and nikon lower end bodies were just too small for me, the alpha is just right. If you decide you like the sony, its a megapixel upgrade in the least. Sony makes nikon's sensors, btw.
If you keep the nikon, and get a 70-300 lens, go get a GOOD tripod as well. I have a manfrotto/bogen with ball head. It is about a $150 tripod/head combo, and worth it. You wont do very well hand holding at 300mm...its possible but not too easy unless you have tons of light!