Hi All,
Is there a way I can read back the module name and form name that is generating an error? I have error handling code that spits up a message box with the error number and description but I would also like to display the form name (if it is being run on a form) and/or the module name that is firing the error. I am thinking that I may want to start writing these values into a table for later reference.
Thanks,
Mark
Read module name / form name during error
-
- 3StarLounger
- Posts: 253
- Joined: 19 Apr 2010, 09:01
- Location: Indiana, USA
Read module name / form name during error
Thanks,
Mark
Mark
-
- 3StarLounger
- Posts: 253
- Joined: 19 Apr 2010, 09:01
- Location: Indiana, USA
Re: Read module name / form name during error
Hi All,
I found this which will return the active form name. It should serve my needs well.
I found this which will return the active form name. It should serve my needs well.
Code: Select all
Dim frmCurrentForm As Form
Set frmCurrentForm = Screen.ActiveForm
Dim frmName As String
frmName = frmCurrentForm.Name
Thanks,
Mark
Mark
-
- 4StarLounger
- Posts: 495
- Joined: 13 Sep 2013, 07:56
Re: Read module name / form name during error
You do not need any code to return the form name.santosm wrote:Hi All,
I found this which will return the active form name. It should serve my needs well.
Code: Select all
Dim frmCurrentForm As Form Set frmCurrentForm = Screen.ActiveForm Dim frmName As String frmName = frmCurrentForm.Name
Both of these will return the form name:
me.name
screen.activeform.name
Access does not expose the module name but it is possible to get it if you hard code it into the error handler for the module, viz:
Code: Select all
Private Sub sGetPostCode
on error goto errhandler
' code here
exithere:
exit sub
errhandler:
select case etc to handle your known cases here for this module
case else ' go to a generic handler with parameters
call errGenericHandler (me.name, "sGetPostCde",err.number, err.Description
end select
resume exithere
End Sub
There is also a commercial product called vbwatch. http://www.everythingaccess.com/vbwatchdog.htm
Regards, Ben
"Science is the belief in the ignorance of the experts."
- Richard Feynman
"Science is the belief in the ignorance of the experts."
- Richard Feynman
-
- 3StarLounger
- Posts: 253
- Joined: 19 Apr 2010, 09:01
- Location: Indiana, USA