error handler question

  • Thread starter Thread starter Josh
  • Start date Start date
J

Josh

I'm using Allen Browne's generic error handling,
http://allenbrowne.com/ser-23a.html, but instead of:
Call LogError(Err.Number, Err.Description, "cmdClose_Click()")
I use:
Call LogError(Err.Number, Err.Description, Form.Name & "_ " &
"cmdClose_Click()")
Because I want to know what Form or Report it was called from. Works fine, but
I have to remember to change Form.Name to Report.Name after I use MZ-Tools free
Error handler to insert the text.

(finally get to the question) Is there something I can use instead of
Form.Name, such as Object.Name (which doesn't work) so that I don't have to
remember to go back and change Form.Name to Report.Name?

Thanks
 
Josh, you can try:
Me.Module.Name

However, that fails when you create an MDE.

What I personally do is to add this line to the top of every module in the
database:
Private Const conMod = "Form_Form1"
or whatever the module name is.
Then pass the constant to the error handler.

This works in all versions of Access, and works correctly when you move code
from module to module.
 
You can use the following as the error handler set up for ez-tools .

LogError Err.Number, err.description, "{PROCEDURE_NAME}" ,
"{MODULE_NAME}"

Module_Name will be replaced with Form_FormName or Report_ReportName for
class modules such as the form and report modules or the the module name for
VBA modules.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
I use MZ tools, and here is how mine is set up:

MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure {PROCEDURE_NAME} of {MODULE_TYPE} {MODULE_NAME}"
GoTo {PROCEDURE_NAME}_Exit

It works wether it is a form, a report, or a standard module.
 
Hey, thanks, guys. Great suggestions all. I'll play around to see which works
best for me, but I really appreciate the help.

I also want to say thanks for all the unpaid volunteer work you guys (and other
people) do with helping out on the newsgroups, I know you've been at it a long
time.
 
Best way to learn is to teach. I believe I have learned far more from these
sites that I have taught.
 
Back
Top