can't find the field 'DoCmd' referred to in your expression

M

M Skabialka

An Access 97 database that has worked for years suddenly says "can't find
the field 'DoCmd' referred to in your expression" when this line of code
runs:

DoCmd.OpenReport stDocName, acPreview

This form runs a dozen reports; the code is the same for every one but some
work and some give this error message, all from modules on the same form!

I checked an old backup copy of the database and the references haven't
changed. I haven't changed any software either. In fact I haven't changed
this form in ages, and the 3 months old backup of the form gives the same
messages.

Debugging and compiling doesn't work either. Nor does decompiling then
recompiling..


What would cause code to run sometimes and not others for the same form,
same code?

Help!
Mich
 
M

M Skabialka

Found the answer - I had added a StartDate field in a table and the report
query had two tables now with a StartDate (different info) and it was
confused about which one I referred to in a date comparison expression. I
have no idea why this ended up showing DoCmd errors. When I ran the report
directly it told me the query had errors to do with that field. When these
were fixed the DoCmd worked also.

Live and learn....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top