Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634

    Unanswered: Access Ate my Code

    I have a form that had code in the open event, the change event of a few text boxes and the click event of a few buttons. I wrote the code yesterday, it worked with no problems. I came in today, opened the form and clicked a button - nothing happened. I went to design view and tried to open the form's module. I got an error about Access not being able to create the VB module. I closed the form, repaired and compacted the db. I then opened the form's module and saw my code. I closed the form and reopened it from a button on another form, the open event fired properly and the button worked this time. I closed and reopened the form and the button stopped working. I went to design view and checked the button's properties, on click says [event procedure], but the module for the form is empty. The other controls that had code also still say [event procedure] in the properties dialog, but the code is gone - empty module. Repair and compact does not fix the problem. I also tried importing just the form to a new mdb and all objects to a new mdb - no joy.

    Does anyone have any idea where my code went. I'm resigned to the fact that I'll be rewriting it, but I'd like to know what happened and avoid it in the future.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Just sounds like a corruption.

    Easiest way to avoid rewriting too much is to obsessively create backups throughout your development.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    With your BA editor open, click on View-->Project Explorer. This opens a box along the left margin of your screen aith all your modules, etc., listed. click on each module. You may have accidentally created blank forms somehow, and your [Event Procedure] pointers might be pointing to a blank module. If there are empty modules, delete them, and see if you can re-point the pointers correctly.

    HTH,
    Sam

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    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.

    http://support.microsoft.com/kb/241141


    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 14:13.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •