Error Handling Routine not being invoked

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

Form_Load_Err:

MsgBox "ERROR...."

End Sub

Open in new window

Patrick O'DeaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Connect With a Mentor Database ArchitectCommented:
The only options I can think of are on the  right side of the Image ... VBA>>Tools>>Options.

Mainly ... Break on Unhandled Errors ..

mx
Capture1.gif
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:


On Error GoTo Form_Load_Err
Remove colon                         ^^

mx
0
 
Rey Obrero (Capricorn1)Commented:
try removing Exit Sub
0
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Actually ... the Colon is not really a problem ... and, the code does work for me as is ....

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

mx
0
 
Patrick O'DeaAuthor Commented:
See attached.
Click form Mainmenu.

Then click "Master Screen".

The system will crash.

Why is the On Error not invoked?
DerekImport--3-.zip
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
No crash.  "pop" appears as expected.

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Tested on both A2003 and A2010 ...

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
I Decomplied, Compacted & Repaired ... see if you still have issue.

mx
DerekImport-MX01.zip
0
 
Patrick O'DeaAuthor Commented:
...

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?
DerekImport--4-.zip
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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 ?

mx
Capture1.gif
0
 
Patrick O'DeaAuthor Commented:

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?



Database5.mdb
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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:
       >>Debug>>Compile
        Note ... after the word Compile ...you 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:

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

mx
0
 
Patrick O'DeaAuthor Commented:
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.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
No time wasted.  So, how were the options set then ?

mx
0
 
Patrick O'DeaAuthor Commented:
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!
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
ok ... no problem.

mx
0
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.