My upgrade path was very similar to Morticia's Keeper.
I started with a D40X -> D90 -> D7200. I still use my D90 as a second body and would totally recommend it as a D40 upgrade. For me the biggest advantages (over my D40X) were the additional focus points, frames per second, higher ISO and internal focus motor so I could seamlessly use legacy glass from my wife's N6006 film camera.
That said, make a list of where you've outgrown your D40. You may find a newer generation D3XXX, D5XXX, D7XXX would be better than a D90 since that camera was discontinued in 2011.