Access problems in my form's coding

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I created forms in Access with coding behind some events. The code worked and
did what I intended. Several times I opened certain forms and began to
receive error messages on code that already worked:
Message:
The expression (on click, after update...) you entered as the event property
setting produced the following error: A problem occured while Microsoft
Access was communicating with the OLE server or ActiveX control.

Once I get this message the code in the form never works properly again.
Identicle code in other forms in the same database will work. I'm working in
Microsoft 2002
 
The symptoms you describe indicate a corruption of the database.

The solution could be a decompile, or removing the Name AutoCorrect problem,
possibly in conjunction with fixing references.

Suggested sequence:

1. Uncheck the boxes under:
Tools | Options | General | Name AutoCorrect
Explanation of why:
http://allenbrowne.com/bug-03.html

2. Compact the database to get rid of this junk:
Tools | Database Utilities | Compact

3. Close Access. Make a backup copy of the file. Decompile the database by
entering 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"

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, and reference ambiguities are
resolved.

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
 
Thank you very much for responding. I am having trouble decompiling the
database. I'm going to search through this forum to see if there's help in
that area. I'm considering just starting again since I'm at the beginning of
a new project, which is to redesign an old database -- and I'll use your tips
to prevent corruption.
 
If it won't decompile, then you do have a corruption.

Here's a trick that may help you avoid starting all over.
You can export individual forms and reports like this:
SaveAsText acForm, "Form1", "C:\Form1.txt"
Then you can import them back into your new database like this:
LoadFromText acForm, "Form1", "C:\Form1.txt"
If you strike one that won't export, it is the culprit, but you may be able
to avoid having to rebuild the others.

Sequence:

1. Create a new (blank) database.

2. Immediately turn off Name AutoCorrect:
Tools | Options | General.

3. Import the tables and queries:
File | Get External | Import

4. Import the forms and reports, using LoadFromText.

5. Copy the text of the modules via the clipboard into the new database.
 
Back
Top