I have found this link to DSLR adaptors for Opiticon scopes.
http://opticron.boson.posiweb.net/PDF/PG46-47.pdf
In view of the camera mount being a ' T Mount ' I am not sure it will work with the D40. The D40 only takes AFS lenses with no M/F switch on the body. This may well result in an ' Err ' message as the camera will assume no lens is mounted.
Don