Avatar of Dustin Stanley
Dustin Stanley
 asked on

VBA Access Errohandler In Modules When Calling Other Modules

Let's say I have multiple modules for my code Module_1, Module_2, and Module_3.

**THIS IS JUST QUICK IN A HURRY SAMPLE BUT GIVES THE IDEA**
If in each Module at the beginning it say If error Goto Errorhandler:
Public Sub Module_1 ()
On error Goto Errorhandler
 Call Module_2
Exit Sub
Errorhandler:
 Yadda Yadda
Exit Sub

Open in new window


Public Sub Module_2 ()
On error Goto Errorhandler
If "" & Value1 = "" Then
 Call Module_3
End If
Exit Sub
Errorhandler:
 Yadda Yadda
Exit Sub

Open in new window


Public Sub Module_3 ()
On error Goto Errorhandler
 'Do Something Here
If Me.Dirty Then
Else
Exit Sub
Errorhandler:
 Yadda Yadda
Exit Sub

Open in new window


Then if there is an error in Module_1 or Module_2....
Which Module will the error handler come from?

This is just a little confusing and I am trouble shooting some modules.
Thanks for the help.
Microsoft AccessVBA

Avatar of undefined
Last Comment
Dustin Stanley

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Scott McDaniel (EE MVE )

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Anders Ebro (Microsoft MVP)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Fabrice Lambert

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Dustin Stanley

ASKER
Sorry for the wrong wording. Honestly I knew this but don't know why I worded it that way.  I wasn't 100% sure but pretty sure. This now confirms it for me.  Generally I do add the Module name to the Error Handler Like So:

Exit Function
ErrorHandler:
 MsgBox "Error " & Err.Number & ": " & Err.Description & " in " & _
   VBE.ActiveCodePane.CodeModule, vbCritical, "Error in  MODULE NAME HERE"
End Function

Open in new window

Dustin Stanley

ASKER
Thank you all for the help. This will help me try to figure out what my exact problem is.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23