• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4795
  • Last Modified:

"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.
4 Solutions
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


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"
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now