The Nikon D40 and D40X will mount a lot of Nikon lenses.
Autofocus is only available with AF-S and AF-I lenses (the ones with internal motors).
Metering is available with AF and AI-P lenses (“CPU lenses”).
AI-s and AI lenses will mount, but won’t meter.
See this page for a good overview of the alphabet soup that is Nikon lenses.
The following lenses will bust your camera and/or lens, according to my D40 manual:
- TC-16A AF teleconverter
- non-AI lenses
- lenses that need the AU-1 focusing unit (400mm f/4.5, 600mm f/5.6, 800mm f/8, 1200mm f/11)
- fisheye lenses (6mm f/5.6, 7.5mm f/5.6, 8mm f/8, OP 10mm f/5.6)
- Old-model 21mm f/4
- K2 rings
- ED 180-600mm f/8 (serial numbers 174041-174180)
- ED 360-1200mm f/11 (serial numbers 174031-174127)
- 200-600mm f/9.5 (serial numbers 120001-300490)
- lenses for F3AF (80mm f/2.8, 200mm f/3.5, TC-16 teleconverter)
- PC 28mm f/4 (serial numbers 180900 or lower)
- PC 35mm f/2.8 (serial numbers 851001-906200)
- Old-model PC 35mm f/3.5
- Old-model 1000mm f/6.3 Reflex
- 1000mm f/11 Reflex (serial numbers 142361-143000)
- 2000mm f/11 Reflex (serial numbers 200111-200310)
If you want more autofocus functionality, get the Nikon D80. If you want more metering, get the D200.