http://www.nikonchat.com/nikon-camera-d40-manual/

How Nikon D40 I can restore the factory settings (completely)?
I want ALL settings I customized individuals to be removed and reset values. I see the manual and it says you have to press two buttons at the same time green, but does not reset the camera completely.
In your custom menu in the settings menu, select Reset Menu
D40 Made easy