• Extract code from corrupt form?

    Author
    Topic
    #459074

    So I just started playing with Access 2007 to prototype an app…. but at some point in the last 24 hours, the .accdb file no longer lets me open up any VBA code: not with Alt-F11, not with the event on any button, etc. I get the typical Windows application error message, with an offer to repair (which it doesn’t) and report the issue (which has gotten boring)

    Compact and Repair: Same Results
    Save As: Same Results
    Office Diagnostics: Nothing found

    Export to another DB worked for all items but one, of course it’s the most complex form I put together. I really don’t want to rebuild that one from scratch, especially as I had some clever hacks in the that frustrated me for the better part of a couple of afternoons (multiple linked subforms).

    Is there any clever way to get the VBA code behind that form out from the .accdb file? That would really save me a lot of work.

    Viewing 1 reply thread
    Author
    Replies
    • #1156412

      Export to another DB worked for all items but one

      Export to another DB don’t work for that one form, but have you try to import it from another DB. I don’t know if that can make a difference.

      • #1156426

        Export to another DB don’t work for that one form, but have you try to import it from another DB. I don’t know if that can make a difference.

        Good ol’ ribbon bar, hiding features from me… but nope, doesn’t work. Same crash when I try to import that one form.

        Thanks for the pointer, I’m sure I’ll use it, but it didn’t fix me here. I guess I’ll have to re-engineer the darn thing. I may have a very early version that can give me a jump start, but I doubt it.

        • #1156432

          Good ol’ ribbon bar, hiding features from me… but nope, doesn’t work. Same crash when I try to import that one form.

          Thanks for the pointer, I’m sure I’ll use it, but it didn’t fix me here. I guess I’ll have to re-engineer the darn thing. I may have a very early version that can give me a jump start, but I doubt it.

          Says a lot for backups. I tend to save any database i am working on about 1/2 dozen times a day. Still that is not helping you any here.

          Can you convert the 2007 database to 2003? If you can that may save your bacon.

        • #1156437

          Are you familiar with the (undocumented, as I understand it) /DECOMPILE command-line switch? If it serves the same function in Access 2007 that it did in prior versions, it might be worth a try. (Save a copy of the database before you try it.)

          You may want to search the Access forum for “decompile” for posts offering more background, but the basic instruction is to open the database from the command line and add /DECOMPILE at the end. For example:

          [indent]MSACCESS NameOfMyDatabase.mdb /DECOMPILE[/indent]As I understand it (and remember — I don’t know if this continues to apply for Access 2007), decompiling periodically is apparently good practice for any database that has lots of code, forms, etc. (i.e., typical front-end databases). It both reduces the database’s size and, in Charlotte’s words, it can “cure some problems you may not even know you had.”

          Good luck.

    • #1156465

      Thanks much everyone:
      1) Saving to 2003 caused a crash, and the 2003-version file still crashed Access 2007 when attempting to open VBA, but it was able to be opened in 2003, and the form and its code examined there
      2) The DECOMPILE switch appeared to repair the file — a life saver. You’d think that “Compact and Repair” might do that, but nooooooo.

      The root cause? I think it may have been closing the database with a breakpoint set in code. I know this has caused problems for me in previous versions of Word, and at one point the code was breaking there even though the breakpoint wasn’t visible — I was able to stop that behavior with “Clear all breakpoints” but shortly after that the VBA was no longer accessible.

      I’ve worked with Access much, much less than I have with Word, but I feel I could already write one of Woody’s “Annoyances” books.

      • #1156513

        I’m glad to hear the /DECOMPILE worked for you. Just a follow-up note:

        My notes on /DECOMPILE say that, to really finish the clean-out, after you do the decompile, you should then (1) go to the VBE window and compile the database, and then (2) Compact and Repair.

        At that point, if I understand this correctly, the corruption (which was probably located in a compiled portion of the file) will hopefully have been discarded (and replaced by the freshly-compiled code).

    Viewing 1 reply thread
    Reply To: Extract code from corrupt form?

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: