Results 1 to 4 of 4
  1. #1
    karxarini is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2014
    Posts
    2

    The database object cannot be opened because the VBA project contained in it cannot..

    Hello,
    first of all please forgive my ignorance I am completely unfamiliar with access.
    I was assigned to "fix" a problem in a computer that is running windows 7 has an avg antivirus that is outdated for 6+ months and it is full of viruses.
    I updated avg and conected the pc to internet after really long time. Widows also installed update.
    They have an access "programm" installed in the pc , when they started it a message appeared :
    "The database object cannot be opened because the VBA project contained in it cannot be read. The database can be opened only if the VBA project is first deleted Deleting the VBA project removes all code from modules ,forms and reports .... "
    If i press ok and proceed the buttons of the program have no respond.
    I am somewhat familiar with SQL SERVER but i have never worked with access before (except some ado.net connections )

    Things that happened before the error :

    1. windows update
    2. avg updated
    3. changed user permissions in registry



    things that i did after the error :

    1. virus scan (cleared 4 viruses )
    2. system was in very strange condition , most startup programs where not running ,desktop appearence changed to a similar of windows 2000
    3. system restore (changed registry permissions in previous state but database didnt work )


    system info :
    windows 7 professional - no sp


    access 2007

    aditional info :
    They have the same programm running in different computers but the database is different (is there any way to retrieve the macros / code from there ? )
    In my reasearch I found that this may be related to access version but I didnt update access .


    Please advice ,
    thank you very much
    -Agis
    Last edited by karxarini; 02-21-2014 at 10:01 AM. Reason: additional info

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    My A2K dB started opening slower and slower until it would sometimes take 3 minutes for the startup form to appear, if at all. Previous backups were exhibiting the same behavior; the dB had been getting progressively worse after each modification.

    I could hold down the shift key and the dB would open, but I couldn't open the startup form and work in the dB. No error messages.

    After about 2 weeks, I finally determined the VBA project was corrupt, even though I could open modules and see the code.

    I googled incessantly, trying to find someway to fix the dB (lots of stress). I tried Compact & Repair (many, many times), tried decompiling (again and again), importing the objects to a new dB..... nothing worked. I finally saw a post that clicked and solved the problem. In essence, the post said "... you must delete the VBA project..." or words to that effect.

    Here are the steps I used to delete & recreate the VBA project:

    1) Compact & Repair (I know... but do it *again* to make sure)
    2) Use the undocumented command "SaveAsText" (google it) This saves all of the VBA code as text files. You can open each module and copy/save the code if you want, but I had 50+ modules..

    This is the key step:
    3) Open each form/report object in design view and set the "HasModule" property to NO. Save the forms/reports.

    4) Compact & Repair
    5) Create a NEW dB. Uncheck autocorrupt... er, I mean uncheck AutoCorrect options and check "Always use Event Procedures" .
    6) Import the objects from the "bad" dB.

    Now the VBA...
    7) There is a "LoadFromText" (undocumented) command to reload the VBA code. I didn't use this because I wanted more control over adding the VBA code. So I opened the text files one by one and copy/pasted the code, starting with the standard modules. The form/report modules call code in the standard modules, so if you do a compile in the IDE, you get errors if the standard module code is not there first.

    8) Then I started with the report VBA code. For each report, I would copy/paste one or two subs/functions from the text file to report module in the IDE. Then, in the IDE, DEbug/Compile, save, close the IDE, compact and repair (C&R), save and close Access.

    9) After all of the report VBA was added, add the VBA for the forms. Same idea.... copy one or two subs/functions, paste, Debug Compile, save, close the IDE, C&R,save, close Access. Open Access, repeat....

    10) Set the startup form name (which form is displayed when Access starts). Relink tables to the BE if necessary.

    Then it is a matter of checking that all of the buttons were connected to their code and testing the dB to make sure all of the code is functioning correctly.


  3. #3
    karxarini is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2014
    Posts
    2
    Omg Im screwed !!
    I hoped there would be a magic button that extracts the code from one database and imports it to the other :/
    anyway thanks a lot for the reply.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Yeah, sounds like can't open the db to even save code as text.

    Have you tried importing to new db file? Can the import wizard even see the bad db? If importing all at once fails, try importing incrementally and opening between each step.

    Is this a split design?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Microsoft Project Object model
    By Mrnorth in forum Programming
    Replies: 1
    Last Post: 06-05-2013, 09:11 AM
  2. Replies: 2
    Last Post: 06-20-2012, 02:18 AM
  3. read only database when opened with an app
    By jpimlott in forum Access
    Replies: 3
    Last Post: 01-05-2012, 07:10 PM
  4. Replies: 2
    Last Post: 04-11-2011, 05:05 PM
  5. Replies: 0
    Last Post: 10-13-2009, 11:54 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums