Its easy if you know where to look!
Under the custom settings menu (the pencil icon), set the remote on duration (option 17). This specifies how long the camera will stay on waiting for a command from the remote once it has been put into the remote mode. I like a setting of 10 minutes. But be aware that the longer this setting, the more it will drain your battery. This setting needs to be messed with only once:
Now, every time you want to use your remote to capture a picture, you need to put the camera into the remote shooting mode. You do this by going to the Shooting mode options (option 4) under the custom settings menu and selecting either the Delayed remote mode or the Quick response mode.
Here is where you can buy a cheap Nikon remote that I can confirm works with the D40. (meritline)