Since, like the D40, the D40x isn't (fully) compatible with certain older lenses available to Nikon, it takes away the typical response of getting the Nikon simply because of the available lenses. You must buy newer lenses to get full functionality. In my opinion, this is a good thing since you've less of a chance to get old rubbish.
The D40x is a nice, light body and is almost the same size as the E-410.
The E-410 is a good body and based on features alone, it's quite a bit better than the D40x. The dust reduction filter is the best of any on the market and I can personally assure its effectiveness in 3.5 years of shooting with an E-1. The Live View is another feature that can't be matched for those stepping up from a compact camera. There are plenty of lenses available at this point, as well as third party flash units and battery packs, etc.
I can't decide for you, but they're similar enough that you should take some time to try them both with your own flash memory card and see what's best for you. Look at what's available for each because with digital bodies, time moves quickly.