Error Handling Routine not being invoked

Posted on 2011-02-24
Last Modified: 2012-05-11
See code below
Note the statement ;On Error GoTo Form_Load_Err:

I am testing the VBA and have removed a table that is in the query qryFillSuppGroup2.  The system crashes with an error 3078 (which is an appropriate error).

The question is : Why is my error routine not invoked?

I am new to this!

Private Sub Form_Load()

On Error GoTo Form_Load_Err:

DoCmd.OpenQuery "qryFillSuppGroup2"
Exit Sub


MsgBox "ERROR...."

End Sub

Open in new window

Question by:Patrick O'Dea
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 5
LVL 75
ID: 34973976

On Error GoTo Form_Load_Err
Remove colon                         ^^

LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34973978
try removing Exit Sub
LVL 75
ID: 34974001
Actually ... the Colon is not really a problem ... and, the code does work for me as is ....

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

LVL 75
ID: 34974025
Something else is going on.  Do you have code elsewhere..

And if you remove the Exit Sub ... you will *always* get the Error message - even when there is no error.


Author Comment

by:Patrick O'Dea
ID: 34974042
See attached.
Click form Mainmenu.

Then click "Master Screen".

The system will crash.

Why is the On Error not invoked?
LVL 75
ID: 34974115
No crash.  "pop" appears as expected.

LVL 75
ID: 34974144
Tested on both A2003 and A2010 ...

LVL 75
ID: 34974175
I Decomplied, Compacted & Repaired ... see if you still have issue.


Author Comment

by:Patrick O'Dea
ID: 34974265

Let me simplify.

I have placed the line x=x/0 and this is not being caught by the On error.

Surely a divide by zero should be caught?
LVL 75
ID: 34974341
The  error *is* caught on my systems ...  see image.
Possibly there is a problem with your Access installation ?
Did you try the MX01 version I uploaded ?


Author Comment

by:Patrick O'Dea
ID: 34974502

Thanks again ,

I tried your MX01 problem but still have the same error.

Incidentally, how do I de-compile??

I had an error a few days ago that did not make sense too.
I wonder is my Access version (recent 2010) okay?
Perhaps, my "Access Options" need to be looked at??

See brand new database5 attached.

Nothing in it except one form with one button which calls VBA.
This VBA error handling does NOT catch the divide by zero.

Any thoughts?

LVL 75

Accepted Solution

DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 34974554
The only options I can think of are on the  right side of the Image ... VBA>>Tools>>Options.

Mainly ... Break on Unhandled Errors ..

LVL 75
ID: 34974580
Decompile - For Reference:
But first, if you have not already:
Open the VBA Editor and from the menu ...Tools>>References ....
If you see any listed as **Missing: <reference name>, including the asterisks and the word Missing, the
you need to fix that first.

Then, follow this procedure:

0) **Backup your MDB BEFORE running this procedure**
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 ...
Close the mdb after the Compact & 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) Close the mdb.
6) 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.

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

*** Executing the DeCompile **EXAMPLE**:
Here is an **example** of the command line syntax  (be SURE to adjust your path and file name accordingly) before executing the decompile:

Run this from Start>>Run, enter the following command line - **all on one line** - it may appear like two lines here in the post:
Also, the double quotes are required.

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

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


Author Closing Comment

by:Patrick O'Dea
ID: 34974633
Oh dear,,

You are 100% correct.

I changed this option a few days ago while tring to resolve a previous problem.

All in fine.

Thanks again and apologies for the time wasting.
LVL 75
ID: 34975214
No time wasted.  So, how were the options set then ?


Author Comment

by:Patrick O'Dea
ID: 34975376
I had it set to "Break on All Errors".

Ironically this setting was made to investigate the other query (which you have just solved).

It has been an evening of me trying to make complications where the actual problem is trivial.

Still, I'm learning!

Thank you and goodnight from Ireland!
LVL 75
ID: 34975441
ok ... no problem.


Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

628 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