I recently had a database crash, hard, to the point where it lost ALL the VBA code. Forms, queries, data – all good, but every line of VBA code gone. I have backups, but I had done several days worth of development work just prior to this and hadn't backed that up yet. (Yes, yes, I know – spare me.) Found numerous others who had experienced this exact same event – ALL code mysteriously vanishes, and nobody had a solution. Apparently just another one of Access's more endearing features.
But one of the things I had been fiddling with just prior to the crash was exporting all code to text files. I have those, and the code there is somewhat newer than my most recent backup, so I'm trying to re-import that. All the normal code modules and class modules load just fine, but when I try to import the code formerly attached to a form, it doesn't go in the right place, complaining that the name Form_DataDS (for example) is invalid. Instead, Access discards the name, creates a new class module, and simply calls it Class1, Class2, etc. I then have to manually copy the code out of the newly created class module into the form's code module, which doesn't exist, due to the crash, although the form's HasModule property is still set to Yes. I have to manually open the form in design view, click on something, anything to create an empty event procedure, which then creates the code module in the VBA window, and only than can I manually copy in the code that Access insisted on putting in a new class module. It doesn't help to set the HasModule property to No, not even completely removing the form.
Is there a way to make this behave properly? I'm kind of alternating between doing all this manually and simply going to older backups, and redoing all the development work. Naturally, neither option is attractive.