mdb works, mde doesn't

AlexRigholt

Registered User.
Local time
Today, 13:39
Joined
Nov 14, 2008
Messages
36
My VBA code works when run in mdb format, but after converting it to mde it aborts at multiple places.

I use Access 2003.
References are all ok.
Code compiles without an error.

What should I check?

Alex.
 
Last edited:
Re: mbe works, mde doesn't

i suspect it is a reference issue - since some references are auto-fixed in an mdb, but cannot be in an mde.

but if your code is just stopping, what message do you get? it implies you do not have adequate error handling.
 
Re: mbe works, mde doesn't

By mbe you mean mdb don't you?

You need to error handle all your functions and subs.
 
Re: mbe works, mde doesn't

Edit: Dave got here before me :)
 
True, I had no error handling - had been in a hurry... It crashes on

DoCmd.RunMacro "Payslip Dialog.Open dialog"

Since it does run as mdb, I agree with gemma-the-husky it will probably be a reference issue. Thanks all!
 
Re: mbe works, mde doesn't

If it's an mde and it crashes when it encounters an error like you initially described, it's most likely not a reference issue. If it was a reference issue all your other DoCmd commands will fail.

Once you error handle all your events, it will display a sensible message and stay open.

Open up your mdb, run the code without error handling and tell us what the error is.
 
Re: mbe works, mde doesn't

Thanks for looking into this again, vbaInet. I spent another 6 hours working on the references without result. I was planning to use a backup copy that worked OK, and import all new objects into it.

When running as an mdb there is no error. When running as mde it crashes at this line:

DoCmd.RunMacro "Payslip Dialog.Open dialog"

I have error trapping on, but is doesn't get triggered. I know it is that line, because I have:

msgbox "1"
DoCmd.RunMacro "Payslip Dialog.Open dialog"
msgbox "2"

and it crashes after I click the first msgbox away
 
Re: mbe works, mde doesn't

Alex, like I previously said run the MDB, not the mde, and tell us what the error message is?

What kind of error handling do you have?
 
Re: mbe works, mde doesn't

vbaInet,

When I run MDB there is no error message!

Error handling:

On Error GoTo Err_2075
... code

Err_2074:
MsgBox "2074 " & Err.Description
 
Re: mbe works, mde doesn't

Code:
Option Compare Database
Option Explicit
Dim Result As Boolean
Dim sFile, sQuery As String

Private Sub Report_Open(Cancel As Integer)
    'On Error GoTo Err_2075
    MsgBox "1"
    DoCmd.RunMacro "Payslip Dialog.Open dialog"
    MsgBox "2"
    sFile = "TabularOverview.xls"
    sQuery = "Payslip Query2"
    Result = ReportExport(sQuery, sFile)
    Me.Caption = ">> " & ReportPath() & sFile
Exit Sub
    
Err_2074:
    MsgBox "2074 " & Err.Description
    
End Sub
 
Re: mbe works, mde doesn't

I don't know why I didn't pick up on this before but you need to error handle in your macro or convert the macro to VBA and error handle there.

The bottom lines of your error handling code should be:
Code:
Exit_Err_2074:
    Exit Sub
    
Err_2074:
    MsgBox "2074 " & Err.Description
    Resume Exit_Err_2074
 
Re: mbe works, mde doesn't

Your error handling, if it even worked, would handle only one specific predefined error. On any other error your MDE will crash without a squeak. Have a look here: http://allenbrowne.com/ser-23a.html and pay attention to the catch-all Case Else.

In your code,
On Error GoTo Err_2075 does not point at Err_2074:
 
Re: mbe works, mde doesn't

In your code,
On Error GoTo Err_2075 does not point at Err_2074:
Good catch there smig ;)

Even with that in place, the macro will still need to be error handled separately or converted to code.
 
Re: mbe works, mde doesn't

Thanks spikepl.

I converted the macro, and get:

Code:
 [FONT=&quot]Private Sub Report_Open(Cancel As Integer)[/FONT]
[FONT=&quot]    [/FONT]  [FONT=&quot]    On Error GoTo Payslip_Dialog_Open_dialog_Err[/FONT]
  [FONT=&quot] [/FONT]
  [FONT=&quot]    DoCmd.Maximize[/FONT]
  [FONT=&quot]    MsgBox "1"[/FONT]
  [FONT=&quot]    DoCmd.OpenForm "Payslip Dialog", acNormal, "", "", acEdit, acDialog[/FONT]
  [FONT=&quot]    MsgBox "2"[/FONT]
  [FONT=&quot] [/FONT]
  [FONT=&quot]Payslip_Dialog_Open_dialog_Exit:[/FONT]
  [FONT=&quot]    Exit Sub[/FONT]
  [FONT=&quot] [/FONT]
  [FONT=&quot]Payslip_Dialog_Open_dialog_Err:[/FONT]
  [FONT=&quot]    MsgBox Error$[/FONT]
  [FONT=&quot]    Resume Payslip_Dialog_Open_dialog_Exit[/FONT]
    [FONT=&quot]    [/FONT]
  [FONT=&quot]End Sub
[/FONT]

As usual, no error message when running as MDB. As MDE it shows me the "1" msgbox, after clicking Ok Access aborts - no error message.
 
Re: mbe works, mde doesn't

Logic dictates that some error exists in your "Payslip Dialog" form. Do you have any code there, or macros? If so, put error handling in everywhere.
 
Re: mbe works, mde doesn't

Logic dictates that some error exists in your "Payslip Dialog" form. Do you have any code there, or macros? If so, put error handling in everywhere.
I mentioned this in my first post but looks like Alex didn't follow this advice.

@Alex: You seem to think that putting error handling on the function which you believe is throwing the error will solve the problem. That's not the case here. If there's code in the Load, Open or Activate event in the the form that you're opening that doesn't have error handling, it will fail. So to re-iterate what me and spikepl (got it right this time ;)) mentioned, you have to error handle ALL your functions/subs.
 
Thanks.

I'll put in error handling code, I much appreciate your advise.
This project has 200+ forms, 150+ reports so it'll take take time to put it in. I need the program to work tomorrow.

The [FONT=&quot]"Payslip Dialog" form has an error indeed. It has about hidden 15 text boxes[/FONT] with calculations, and when I remove them all, the error disappears. If I leave one - it doesn't matter which one - on opening the form Access aborts.
 
Re: mbe works, mde doesn't

Check out the free MZtools - that would immensely ease the task of creating error handlers all over
 
Re: mbe works, mde doesn't

alex

if you have a runtime database, and you get an error, the program just stops. i don;t often use, so i am not sure if you get told what the error is.

so you are trying to open a form which may fail for any number of reasons

- the form's query doesn't work
- some code in the form fails
- some lookup in the form fails
etc etc

now if you handle errors, then at least your program can report the erorr, and retire gracefully.

but a "normal" properly debugged form will not crash anyway - so you need to investigate why the form is crashing, as well as putting in some error handling.
 

Users who are viewing this thread

Back
Top Bottom