If this is what I think it is, then I have to ask you if you have 2 versions of MSAccess on your computer and if you've perhaps imported a form, module or report from one mdb file to another and then started coding without immediately debugging after the import?
If this is the case above (or you can try this as a solution), then you'll need to open the mdb file using the /decompile option (ie. Start -> Run, then "C:\Program Files\Microsoft Office\....MSAccess.exe " "c:\<dbname>" /decompile), delete that form, module, or report. Close the mdb and open again with the /decompile option. Create a new form, module, or report with the exact same name....add 1 or 2 lines of code to the module or a text box with a few lines of code to the form/report. Close and reopen again with the /decompile option. Delete the form, module, or report, and reimport or rewrite. And make sure you immediately debug if you're importing WITHOUT writing any new code. It stems from a problem with a *.dll file when you have 2 versions of MSAccess on the same computer. I discovered this problem after a lot of trial and error and nailed it down to this problem and solution. Importing to a new mdb does not work and the problem needed to be fixed with the corrupt form, module, or report. Microsoft doesn't specifically address this problem (other than say it stems from a dll file) and this solution but it does work. Usually I also got an error when trying to debug in the mdb.
You can also try the above to see if this works in your particular sitatuion. I can't remember the exact error and wish you had related what error you got when you opened the mdb or form but doing the above procedure might help. I believe the symptoms were the same though as you've described (ie. missing code, a wierd error when attempting to open the form, report or module, or code not firing). I got in the habit though of debugging, compacting and repairing often, even after writing a few lines of code and especially after importing into another mdb file.
What is the exact error you get on Access not being able to create the VB module when first opening the mdb or form? Do you have 2 versions of MSAccess on the same pc? Please let me know and if this solution works for you.
You can also check to see if perhaps you don't have some functions/procedures with the same name which could also be problematic.
Last edited by pkstormy; 07-20-07 at 13:13.
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)