1

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.

Jerry
  • 1,775
  • 4
  • 22
  • 40

2 Answers2

5

In addition to the method suggested by @Remou, you could try the SaveAsText method to save a code module to a text file.

Application.SaveAsText acModule, "Module1", "D:\Access\Module1.txt"

However, that doesn't satisfy your desire to do it without using Access.

Try a decompile operation on the chance your project includes saved compiled code which has been corrupted. You can find detailed instructions for decompile in the 2 answers to this Stack Overflow question: ms-access: HOW TO decompile and recompile

After decompile, make sure all your modules include Option Explicit in their Declarations sections. Check the project's references, and fix any that are broken (missing). Then run Debug->Compile from the VB editor's main menu to verify your code compiles without error.

Those steps are the best I can offer to reduce potential for continued corruption problems.

For integrating source control with Access, start with this selection of related Stack Overflow threads: site:stackoverflow.com ms-access version control

Community
  • 1
  • 1
HansUp
  • 95,961
  • 11
  • 77
  • 135
  • I followed the steps in your first link, 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. – Jerry Nov 21 '11 at 23:34
  • Also will start using this script to get a dump of my code to store in source control.http://stackoverflow.com/questions/187506/how-do-you-use-version-control-with-access-development – Jerry Nov 21 '11 at 23:34
0

Folks

We're having the same problem. There is a bug in SP1 that causes it. If you keep opening the database, you'll finally end up with a backup that works - rename the old one BROKEN and remove the _backup from the new database, and you are oky till your next bit of development. Our IT guys (Microsoft Gold Partners) are looking at a fix reported on http://answers.microsoft.com/en-us/office/forum/office_2010-access/access-2010-sp1-you-receive-random-crashes-in/d2bf6175-075a-4a12-a2b1-f55d40af271b

I may go take a look at decompile/recompile however as some of our database have come all the way up from Access 97, to 2000, 2003 and now as mdb/2003 file format still, running under 2010. Having said that, converting to accdb/2007 seems even worse!