Link to home
Start Free TrialLog in
Avatar of rlwhitney
rlwhitney

asked on

Access Error - Visual Basic for Applications Project in the database is corrupt - when app opens

Using Access 2003. I have a rather large Access app, which is a "front end" for a SQL Server 2000 database. I develop in the MDB then, when I reach a release point, I compile to an MDE. The users don't see nor have access to the MDB - they can only access the MDE. When I tried to open the database this morning, it threw this error:

Visual Basic for Applications Project in the database is corrupt

Googled the issue - the only solutions I found had to do with (1) compiling a 2003 mdb under prior versions (that's not the case here), and (2) running under an incompatible access runtime (which also does not apply).
I can load the database, but not run it. If I attempt to copy, export, or view any objects, the same error appears.
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Does a new copy of the mde do the same?

Have you just installed Office2003 SP3 (and thereby wrecked everything(:-))?
<When I tried to open the database this morning,>

Was this on the development machine, or an enduser machine?

Also: Are you sure that your target machine has the correct References installed? For example, if you've used a 3rd party ActiveX control, your target machine will have to have this control installed. Also, if you have references to Office applications (like Word 2003 or something), then your target machine must also have those references.
The first thing to do right now is to backup your 2003 .mdb.  You may have encountered corruption to the project file in which case you are in for an unpleasant but not necessarily unsolvable situation.

Project File corruption was a new bug introduced in 2000 an has been a problem ever since.  Though Microsoft does not talk about it much I have talked to Microsoft including everyone from their Project Managers, Testers and even demonstrated it in person for their Developers (they were working on Office 2007 at the time).  Below is a few KB's that do no justice to the problem but do offer a few tips.

http://support.microsoft.com/kb/225946/en-us
http://support.microsoft.com/kb/294755/en-us

After you backup your .mdb we need to find out if you .mdb has a corrupt project file and if so how bad it is.  Make sure you have that backup, you may find you will go back to it A LOT while trying to recreate a solid .mdb again.  Also keep close at hand any recent backups you have made to your .mdb (hopefully you have plenty to pick from.

After that try to decompile your Access .mdb.  For example, click Start, then Run and then enter (substitute "C:\Dev\YourApp.mdb" with the actual path and file name of your .mdb) ...

"C:\program files\Microsoft Office\OFFICE11\MSACCESS.EXE" "C:\Dev\YourApp.mdb" /Decompile

If that doesn not crash on you you are in luck, if not let me know and I will let you know where to go from there.
Assuming no crash, open the app and then open any module.  Select 'Debug' from the Pull down Menu then select 'Compile All Modules'.
If there are issues with the code will usually show up now, if not move on to a compact, repair and then compile a new .mde.  With any luck the new .mde will not have the same problems.

If in fact you have a corrupt project file this is going to be more complicated and there is no set answer to what you need to do to recover so if this turns out to be the case just be patient, I will ask a few questions to figure out how bad it is and what recovery options you still have.

Rick
Avatar of rlwhitney
rlwhitney

ASKER

peter57r - sorry for the confusion. The error was in the MDB file. The existing MDE (made several days ago) runs fine. Corruption is in my development app (the MDB file). SP3 is on this machine, but it wasn't just installed; it's been there for awhile.

LSMConsulting - This was the development machine. The enduser machines only have the runtime. RE: references - the development PC had the references as of yesterday (I was working in the MDB most of the day). Can't get into VB Editor now to check reference listings, but no change that I know of would have caused file lose. And, just to be sure, I tried the MDB on the other machine in my office, which also has Access 2003; same error.
An inability to access the VB Editor is a tell tale sign of project file corruption.  If you haven't already backed that .mdb up do it now.  Once that is done a damage assessment and recovery plan can be figured out.  Hopefully you haven't password protected the VBA code less your options will be limited indeed.

Rick
Rick Rickards:

Reviewed the KB articles. They both address earlier versions of Access, and as you commented, don't really do justice to the issue in Access 2003.

I've backed up the broken database, and am playing with a copy. With Access 2003, I've learned to backup often. If I can't recover this mdb, I've lost about 8 hours work - painful (who likes to code the same thing twice?) but not fatal.

When I try to decompile the database, I get the same error.

As a side comment, I worked with Access 2000 for years, and never had a corrupt database. Since going to Access 2003, I have it happen quite a bit (it has caused me to hone my backup skills, however). Just seems to me that Access 2003 is especially "fragile".

No password protection on the VBA.
Project file was not solved in Access 2003, in fact I've found more bugs in 2003 than in 2000 so much so that I'm inclined to believe they created more bugs in 2003 than they fixed from their earlier versions 2000 and 2003.  As for Project File Corruption I can assure you they didn't fix that.   When I met with them on site back in 2005 they still had yet to see any one demonstrate how to reproduce Project File Corruption.  I solved that issue for them although I've yet to see the evidence that they ever fixed it, I can only say that Microsoft received step-by-step instructions on how to corrupt a project file 100% of the time.

Anyway, back to your problem, I hate to break it to you but everything I'm seeing screems Project File Corruption.  I can help but I'm going to have to ask a lot of questions so we can asertain what options are available to us and which ones or not.

1) Have you identified the most recent backup that does not have corruption in the project file.  An easy way to know for sure is to decompile the .mdb then compile the code then compact and repair.  If all steps succeed we have a good foundation to start with.  What we want to do right now is find the most recent copy you have in backup that is good.

2) Are you able to get to any VBA window?  For example, can you get to the code behind the form?  

3) Do you have a password protecting your VBA code?  If so any chance we had to get your code is probably lost

4) Please tell me you've made a backup of your .mdb as originally suggested.  The longer you wait the worse it gets.  .mdb's with corrupt project files self destruct the more you fuss with them so it won't be uncommon to save one piece and then have to start again from a fresh backup before we can save another.

Rick
Rick,

The most recent working database backup is 11/28/07 @ 8:31 AM. I've confirmed that it's OK (can compact/decompile/compile, and it runs). Was able to create an MDE from that version. So my loss is only about 8 hours of coding. Thankfully, Microsoft's gift for making buggy development tools has made me an advocate of frequent backups. In this case, I should have backed up a few times during the day, but got sloppy. So I may be "Microscrewed" again. Anyway ...

I have renamed the corrupt database BROKEN.MDB, and have backed it up, also.

When I open BROKEN.MDB, I've been unable to open the VBA editor, or view any "code behind" form. I'm unable to compact or decompile it.

I haven't password-protected the VBA code.

And yes, I've got backups o'plenty (except for the most recent 8-hour effort).

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Rick_Rickards
Rick_Rickards
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Rick,

I'm able to grab the SQL code from a query, which saved me some time. And since my tables live in SQL Server 2000, I'm OK as far as my data. I can also open a report, and cut & paste. But I haven't been able to view code any way I've tried.

Long ago, I wrote a script which first backups the database with a timedate stamp in the name, then opens the file. So it's as easy to backup and open, as it is to open; I just got lazy and/or stupid, and am paying the price.

Thanks for all your help on this one ... I've already started re-doing the lost work.

Rob Whitney
You're most welcome.  Sorry for your loss but hope the above helped to mitigate the damage.

Rick