Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to export code from a corrupt database?

Status
Not open for further replies.

Jarekb

Programmer
Mar 30, 2007
33
US
Last week I was modifying portions of two modules in an access 2010 db when the program crashed, and would crash every time I tried opening up the db thereafter. I was able to create a new database and import the tables and queries from the corrupted one, but when I tried to import the forms/macros/modules the new database would start crashing also. I keep daily backups, but ended up losing several hours worth of work. This happened twice last week, each time MS Access would crash without warning and the VBA was unrecoverable.

The functionality works as intended until the db crashes seemingly at some unknown point. There must be some sort of issue with my VBA code, since this only started happening when I started modifying the module last week, but I can't pinpoint it since the crashes actually occurred when nothing was being executed. Ie during save.

Does anyone know if it's possible to export the VBA out of access without exporting it to another database? Ie export it without having to use MS Access to do so. On a related note, has anyone created a library that exports query definitions, table schema, and all VBA to text files that I could drop them into source control?

Thanks.
 
Can you get into the VB editor?
Can you export the modules?
Can you copy and paste the code?

If it is corrupt I would just copy and paste. But their are lots of utilities for saving objects to text files. Here are some links. I have a real good utility somewhere that has great features for saving and object to text and then rebuilding the form/report/table/query from the text file. I will look for it, but google it is out there.

 
Thanks for the answers so far.

Mdbdoc doesn't look like it exports the actual code from the module. It shows a list of modules and functions within those modules, but only displays the number of lines within each, not the code.

I did come across this post on StackOverflow that has a script to export modules, that uses the SaveAsText method to export the data as described in MajP's links.
This also crashes when the corrupted db is opened. For working databases this works great to get a dump of the vba and I'll probably start using this to get the code into source control.

Both of the above open up access to export the code and crash when doing so. Is there anything that doesn't require MS Access to run?
 
SOLVED

I followed the steps here , held shift to bypass startup code execution, then did a compile and repair on database. Not sure if it was the decompile flag that did it or simply running the compile/repair process, but was able to recover all my code.
 
thanks everyone for this thread. I used to get lots of access crashes when writing vba but haven't since I adopted the following policies:
- NEVER edit anything when code has been suspended by breaking at an error or setting a breakpoint. ALWAYS reset and then edit.
- After writing vba, close the database first and only then exit access.
- Compact regularly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top