?
Solved

Corrupted VBA

Posted on 2014-09-22
6
Medium Priority
?
733 Views
Last Modified: 2014-09-23
Hello, I imported a form from a corrupted database.  I believe this is the source of my corruption.  I can now no longer view the code contained in any form as the db crashes each time I try to do this.  I have tried to make a new db and import the forms but it wont import.  

If the VBA project is corrupted then how can you fix it?  Or you can not fix it?  I cant believe that you would basically have to throw away the db and start all over. I dont have a good backup.  At least I am early in db creation so having to start over is not that bad.   I have been working on this for hours and I give up.  

thank you
Untitled.jpg
0
Comment
Question by:pdvsa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 2000 total points
ID: 40338321
You can try opening Access and DB with the /Decompile switch:

"C:\Program Files\MO2003\Office11\msaccess.exe" /decompile "C:\OPR_FE.MDB"

changing this to the correct path for MSAccess.exe and your DB.

That may or may not fix it.   Other options:

1. Recover everything from the DB except code on your own.  You can use the SaveAsText and LoadFromText methods to recover objects if you can't import them.
2. Use a backup (and I realize you said you didn't have a good one)
3. Use a professional recovery service. Maybe expensive and results can vary depending on the corruption

Jim.
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 40338348
There are two things you can try, if they don't help I guess you're out of luck.

1. Decompile and recompile the database. Follow the following steps:
    a. Create a new shortcut to the Access executable
    b. Add the path to your db
    c. Add the /decompile flag to the end of the shortcut
        The final path should look some thing like this (including the double quotes and spaces):
        "C:\Program Files\Microsoft Office\Office14\MSACCESS.EXE"  "C:\Users\MacroShadow\Documents\Corrupt db.accdb" /decompile
    d. Launch the shortcut
    e. Close that instance of Access
    f. Open your db (not with the decompile shortcut) while holding down the shift button as to bypass any startup code
    g. Compact the decompiled database while holding down the shift button as to bypass any startup code
    h. Open the VBE, on the Debug menu, click COMPILE
    i. Save the project
    j. Repeat step g

2. Recover module source code. Follow these steps:
    a. Run this line of code to recover the code:
        Application.SaveAsText acModule, "ModuleName", "C:\PathToSaveRecoveredModule\ModuleName.txt"
    b. Create a new db
    c. Run this code to load the recovered module in the new db.
       Application.LoadFromText acModule, "ModuleName", "C:\PathToSaveRecoveredModule\ModuleName.txt"
0
 
LVL 38

Expert Comment

by:PatHartman
ID: 40339250
You don't say what version of Access you are using.  In addition to the other suggestions I have occasionally succeeded in opening a corrupted database by using a different version of Access.  So, if you are using A2013, try opening the app with A2010 or A2007.  If it is an .mdb, you have a lot more choices.  I can't tell you why this worked for me, but it did.  In fact, I had one database that was such a nightmare that I ended up adding code in my login form so that whenever I closed the database (my ID personally, I didn't want this happening for the users), I had code that exported all the forms, reports, queries, modules to text so that if I opened the database the next time and it was corrupted (happened about 60% of the time), I could rebuild it.  Now I add this code to all my databases because it gives me some measure of source code control.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Closing Comment

by:pdvsa
ID: 40339607
that fixed it!  thank you.  

Looks like Jim responded a tab bit earlier.
0
 
LVL 58
ID: 40339659
Now don't forget those backups<g>

Jim.
0
 

Author Comment

by:pdvsa
ID: 40340029
I was lucky that it worked.  I just backed it up.  thanks for the reminder though.    thank you Pat for that.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question