"Visual Basic for Applications project in the database is corrupt"

My Access application has got several this kind of error messages today (after I failed to save the form), any solution for this kind of problem? How to avoid this and how to repair the file ? Thanks a lot.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Patrick MatthewsCommented:
Hello heyday2004,

Please review the material posted here: http://www.granite.ab.ca/access/corruption/corruptobjects.htm

In summary, the article suggests:

1) Creating a copy of the corrupt object
2) If that doesn't work, try a decompile (link to work steps for that provided in article)
3) If still no joy, import all objects to a new database



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Following is similar to Patrick"s suggestion  - slightly different order and a few more options.

To avoid after you get it fixed take a look at http://www.thenelson.name/  "Save backup, decompile, compile batch file". I use this often. Sometimes several times a day.

Steps (approximately in order) to use to fix a corrupted Access database.


2) Compact and repair

3) Use jetcomp.exe  http://support.microsoft.com/default.aspx?scid=kb;en-us;Q273956

4) decompile: in run: msaccess "dbPathName.mdb" /decompile
   Compact/repair:  in run: msaccess "dbPathName.mdb" /compact
   compile: in VB editor: debug> compile

5) Use a backup (you have a lot of those -- yes?)

6) If you can identify one or a few forms or reports causing problems, copy the problem form/report from a backup.  Or copy and paste a new copy of the form/report then copy and paste the code from the old form/report into the new form/report.  If a module, copy the code, create a new module, paste the code into the new module.

7) Create a new database, use File> Get external data> Import to get all objects of the damaged database and set up the options again.

8) Try a recovery tool:

9) Hire a company to repair the database  http://www.pksolutions.com/services.htm

Additional information:
How to Troubleshoot/Repair Damaged Jet 3.0 and Prior Databases

How to Troubleshoot Corruption in a Microsoft Access Database

Corrupt Microsoft Access MDBs FAQ
These people have a good utility for recovering Access databases:
Patrick MatthewsCommented:
Nice to have you back, Dave :)
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
If the VBA for your project is corrupt, the only fix for it is to attempt to move it to a new, blank database. Decompiling and such won't hurt, but as thenelson said make SURE that you make a copy of the db before you try this. In most cases moving to a new db will fix this, if not you can try using the undocumented SaveAsText/LoadFromText methods to try and recover. To use, then, do this at the Immediate window:

SaveAsText acForm, "FormName", "c:\somefolder\FormName.txt"

In the new database, run this in the Immdiate window:

LoadFromText acForm, "FormName", "c:\somefolder\FormName.txt"
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.