Serious error on open of database

buratti

Registered User.
Local time
Today, 01:08
Joined
Jul 8, 2009
Messages
234
Earlier today I posted a question about why my database would be responding slowly in design mode. It wasn't anything serious, but more of an annoyance. I now have a more seroius error that I dont know is realted to my prevoius problem or not. I deleted my previous post and am now starting this one.
On open of my database i get the error, "The database cannot be opened because the VBA project contained in it cannot be read. The database can be opened only f the VBA project is first deleted. Deleting the VBA project removes all code from modules, forms and reports. You should back up your database before attempting to open the database and delete the VBA project"

Why am I getting this error and how do I fix the problem.

A little more info: Like I stated earlier, I was having a problem, but nothing serious, with the design view of forms "lagging", meaning in short the hour glass would popup for a few seconds on random clicks and in places that it usually shouldn't lag. I worked around it for a while today and made lots of updates and modifications to my database. I double and tripple checked that all my modifications were working correctly, then saved and closed the database and took a little break from it. I came back to it right now, tried to open it and I get the message listed above. please help!!!

I do have a backup copy of the state it was in BEFORE todays updates, but if all possible I would like to fix my current version, and not loose the 6 hours spent on it today!
 
Sounds like a fatal error there.

Hold down the Shift Key before you double click the icon to open your database, keep the key held down until your database opens.

If it does open, hold down Shift again and Compile & Repair, then go to the VBA editor -> Debug menu -> Compile, perform the Shift & Compile/Repair again. If Access throws some errors, fix them and repeat the process.

If this fails, create a new database shell and import all your objects into that shell.
 
Sorry, i guess I should have posted everything I have already tried. I have done all of the following with no luck:
Hold SHIFT while opening: opens database, but every time I open a form or anything that any VBA is attached to I get that same error, which is just about every object inside my DB. The error pops up whenever I click "Database Tools - VBA Editor", and any "Event Procedure" inside a design view of a form.

I have tried creating an empty "Shell" of a database and as soon as I try to import from my bad DB, that same error pops up.

If I try to EXPORT from inside my bad DB to the empty shell db I get the same error

If I copy to clipboard any form/query/report from inside my bad db and try to pase in inside my new one, I get the same error.

Compact and repair throws up dame error

I want to post a copy here so someone can take a look at it, but the regular file size is 13MB and if I zip it up I can only shrink it down to 2.10MB, just over the file size limit and it wont let me upload. Any suggestions on this, or any administrator listening that can temp unlock the filesize limit for me so I can upload?

Now onto more bad news... this one about my backup copy. Although it is working fine at the moment (less 6 hours of updating yesterday), if I go to VBA editor and try to compile it, it crashes and says Access has to close. Happens every time. What acn be wrong with this now???
 
In the copy that is "partially", make another copy, delete all the code - by setting the Has Module property of the form to No, Compile. Delete all the macros from this copy too and Compact & Repair.
 
By the "Partially' copy do you mean the backup that crashes on compile or the original that I am having the major problem with? And to delete all the code the way your're suggesting I have to set the Has Module property to no for each form in my DB? So, after that is completed, how do I get my code back?

If you were refering to my backup copy above, I will work on that also, but I do not want to give up on my original copy just yet. Is there any way I can open my db file with some other program and extract all the VBA code, or somehow copy it to a text file then I can reinsert it into a working copy of my DB?
 
That was meant to be "partially" working, i.e. your backup copy ;) You copy and paste the code from the other db into the copy.

Here:
Code:
Public Function CopyCode()
    Dim accApp As Access.Application, mdlFrom As Access.Application
    
    Set accApp = Access.Application
    
    accApp.OpenCurrentDatabase "Full path to db"
    
    Set mdlFrom = accApp.VBE.ActiveVBProject.VBComponents("Module importing from").CodeModule

    Application.Modules("Module importing into").InsertLines 1, mdlFrom.Lines(1, mdlFrom.CountOfLines)

    accApp.CloseCurrentDatabase
    
    Set accApp = Nothing
End Function
 
Last edited:
Thanks... That code threw up a few errors, but no worries though. I found which line of code was causing my backup to crash on compile, and removed it. So my backup is now working just fine, and I made a backup copy of that. I guess I'm officially giving up of trying to repair my original copy and will just redo any updates to my backup (which is wil now be my main copy). Thanks for your help though!!!

Another quick question though. I'm sure I can find out myself what code to use to attach to a button or somethiong to "auto backup" my database, but is there any way to have code determine if anything "design wise" was changed during the session and if so, then run the backup, if not just close?
 
Last edited:
The Modules collection is for modules that are open in the VBA editor, so the module you're importing into needed to be open but it would have been easy to sort out if you went through the ActiveProject path.

Design changes by whom? Isn't it supposed to be just the Developer or the Administrator that should be allowed to make design changes? Also, in design view code is not running so there's no way of detecting it unless via some sort of API, but this is an unusual request.
 
yes you're right, technically speaking, I would be the only one making changes to the design, and this "backup code" would be for me when I forget to backup, which happens a lot! Lucky for me this last backup I am working off right now was a recent one. The last time I backed up before that was a long time ago, jsut because I forget!
 
i think its probably happened to all of us at one time or another. occupational hazard, i guess - the fortunate thing is it probably takes less time to redo changes the second time around!

I keep version changes of all software, and a version history log, so I know what i did!
 
I don't know of any such "backup" procedure I'm afraid.
 

Users who are viewing this thread

Back
Top Bottom