Microsoft Access says object doesn't exist when compiled to an mde file

Posted on 2007-08-08
Last Modified: 2013-11-28
I am developing in Access (have tried this on both 2003 and 2007).  

I have a main form with a subform, and the subform has a listbox on it.  

I've got code in the listbox double click event that is as follows:

  Private Sub lstAwards_DblClick(Cancel As Integer)

      DoCmd.OpenForm "frmAward", , , , , acDialog
  End Sub

The idea here is that the listbox opens the form frmAward and when that form closes, it requeries the listbox (which is the listbox that was just double clicked).  The reason is that the form that opens, frmAward, is a detail form for the information shown in the listbox.  If the user changed the name or some of the information shown in the listbox, I want it requeried.

When I run this code (double click on the listbox), the form frmAward opens fine.  When I close that form I get the error message:

"The experssion on dbl click you enetered as the event property setting produced the following error:  The expression you entered refers to an object that is closed or doesn't exist"

I never close the main form / subform.

This only happens if I create an .mde version of the database.  If I run this from the .mdb, it works fine.  I've messed around with this code a number of ways.  If I remove the acDialog parameter on the form, it goes through fine.  If I don't open the form (comment out the docmd.openform line), it requeries the listbox fine.

I am at wits end.  Anyone help me figure this out?

Question by:rbertke
    LVL 11

    Expert Comment

    My hunch is that the form or db has become corrupted in some way  

    Try creating a completely new database and then import all objects from the existing one and try again

    LVL 19

    Expert Comment

    try opening the form as an object as below. if it still doesnt work, the form may be corrupt so it may be quicker to just recreate it from scratch. copy and paste the code into notepad and the back into the new form.

    Dim frm As New Form_frmAward
    Set frm = New Form_frmAward
    frm.Modal = True
        'do whatever
    set frm = Nothing
    LVL 75

    Expert Comment

    by:DatabaseMX (Joe Anderson - Access MVP)
    A **DeCompile** may help here ... (on the MDB before creating the MDE)

    But first, if you have not already:
    Check for any **Missing References via the VBA Editor>>Tools>>References ....

    Then, follow this procedure:

    0) **Backup your MDB**
    1) Compact and Repair the MDB, as follows:
    Hold down the Shift key and open the MDB, then from the menu >>Tools>>Database Utilities>>Compact and Repair ...
    2) Execute the Decompile (See example syntax below) >> after which, your database will reopen.
    3) Close the mdb
    4) Open the mdb and do a Compact and Repair (#1 above).
    5) Open the mdb:
        a) Right click over a 'blank' area of the database window (container) and select Visual Basic Editor. A new window will open with the title 'Microsoft Visual Basic' ... followed by then name of your MDB.
        b) From the VBA Editor Menu at the top of the window:
            Note ... after the word Compile will see the name of your 'Project' - just an fyi.

    6) Close the mdb
    7) Compact and Repair one more time.

    *** Executing the DeCompile:
    Here is an example of the command line syntax  (adjust your path and file name accordingly) for executing the


    Run this from Start>>Run, enter the following command line ...

    "C:\Program Files\Microsoft Office\Office\Msaccess.exe" /decompile


    For more detail on the Decompile subject ... visit the Master on the subject (and other great stuff) Michael Kaplan:

    LVL 58

    Accepted Solution

    MDE's have a slightly different error handler than MDB's. Perhaps this is an error in your form frmAward? For example:

    On Error Resume Next
        DoCmd.Close acForm, Me.Name
        gfResult = Me.chkSomething   ' <--- generate silent error

    I'm just guessing, really, because I tried with a small database containing two forms and your code works as expected in MDE format.

    Perhaps try this:

    On Error Resume Next
          DoCmd.OpenForm "frmAward", , , , , acDialog
          MsgBox "form closed"
          If Err then MsgBox Err.Description: Err.Clear

    By inserting message boxes, you will be able to find the line that actually generates the error in the MDE format.

    Another trick, much lighter than message boxes, is to update the form caption as it moves along the code:

          Me.Caption = "about to open frmAward"
          DoCmd.OpenForm "frmAward", , , , , acDialog
          Me.Caption = "frmAward closed"
          If Err then Me.Caption = "Error " & Err.Number
          Me.Caption = "about to requery"
          Me.Caption = "requery done"

    Thus, when you get the error message, read the form's caption and you know where your code stalled.


    Author Comment

    It turned out to be the code in frmAward.  That form is quite complex  and it took commenting out all of it and then working my way backward to find a single syntax error.  It is very strange that it was only after the form closed that it threw the error.  It was the line saying that .mde's have different error handlers and to check on the frmAward that led to the solution.  I'm afraid I would never have found this, I was convinced that it was access not seeing the listbox (and the corruption made sense, but didn't fix it).  Thanks all!
    LVL 58

    Expert Comment

    Welcome and grats on finding the problem!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
    With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now