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

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?

Who is Participating?
harfangConnect With a Mentor Commented:
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.

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

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
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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:

rbertkeAuthor Commented:
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!
Welcome and grats on finding the problem!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.