There are many things that can trigger this message.
A common one is where you are using an event to do something which triggers
a chain of events. For example, if you use the KeyDown event of a control to
move to a different record, that will trigger the control's Change event,
BeforeUpdate, AfterUpdate, LostFocus, and Exit events, and then the form's
BeforeUpdate, AfterUpdate, possibly AfterInsert, and Current events, and
then the Enter and Got Focus events of the next control. If anything goes
wrong in that chain, or if any of those events trigger further events (e.g.
if the form's Current event dirties the form) you can get the message.
Another common reason for the problem is a corruption in the VBA code. In an
MDB, Access keeps 2 copies of the code: the text version (what you read and
edit) and the compiled version (what actually executes.) When you change the
form's design, Access creates a backup of the form (so you can revert to the
saved copy), so it is now juggling 4 copies of the code, and sometimes it
gets confused between the copies. A decompile solves this kind of
corruption. To decompile, enter something like this at the command prompt
while Access is not running. It is all one line, and include the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"
Access 2000 and later have a "feature" called Name AutoCorrect. It's a neat
idea, and the idea is that you can rename a field in the table, and any
queries, forms, or reports will still know how to refer to the field even
though the name changed. In practice, this is badly flawed with dozens of
known bugs, performance penalties of an order of magnitude. It is also the
best way I know to corrupt the database (other than pulling out the power
plug in the middle of a write.) A database corrupted in this way can also
generate this message (amongst many others.) More info:
http://allenbrowne.com/bug-03.html
Bad references can also contribute to this problem.
Suggested sequence:
1. Uncheck the boxes under:
Tools | Options | General | Name AutoCorrect
2. Compact the database to get rid of this junk:
Tools | Database Utilities | Compact
3. Decompile.
4. Open Access, and compact again.
5. Open a code window.
Choose References from the Tools menu.
Uncheck any references you do not need.
For a list of the ones you typically need in your version of Access, see:
http://allenbrowne.com/ser-38.html
6. Still in the code window, choose Compile from the Debug menu.
Fix any errors, and repeat until it compiles okay.
At this point, you should have a database where the name-autocorrect errors
are gone, the indexes are repaired, inconsistencies between the text- and
compiled-versions of the code are fixed, reference ambiguities are resolved,
and the code syntax is compilable.
If it is still a problem, the next step would be to get Access to rebuild
the database for you. Follow the steps for the first symptom in this
article:
Recovering from Corruption
at:
http://allenbrowne.com/ser-47.html