?
Solved

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

Posted on 2007-08-08
6
Medium Priority
?
569 Views
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
      lstAwards.Requery
 
  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?


0
Comment
Question by:rbertke
6 Comments
 
LVL 11

Expert Comment

by:Stephen_Perrett
ID: 19659142
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

Steve
0
 
LVL 19

Expert Comment

by:frankytee
ID: 19659207
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
0
 
LVL 75
ID: 19659387
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:
       >>Debug>>Compile
        Note ... after the word Compile ...you 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

decompile:

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

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

"C:\Access2003Clients\AzDoc\Pgrm\AzDocPgrm2K3.mdb"

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

http://www.trigeminal.com/usenet/usenet004.asp?1033

mx
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 58

Accepted Solution

by:
harfang earned 2000 total points
ID: 19659434
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
      lstAwards.Requery

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"
      lstAwards.Requery
      Me.Caption = "requery done"

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

Cheers!
(°v°)
0
 

Author Comment

by:rbertke
ID: 19667081
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!
0
 
LVL 58

Expert Comment

by:harfang
ID: 19667151
Welcome and grats on finding the problem!
(°v°)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month17 days, 12 hours left to enroll

830 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