Yadtrt
asked on
Error handling
Im writing a procedure to handle some errors, my project has more than 70 forms, and I have to copy that procedure to On Err event of all those 70 form.
Is there any way that automate this process to avoid adding this procedure to 70 from?
Is there any way that automate this process to avoid adding this procedure to 70 from?
This is a better link:
http://www.mztools.com/v3/ mztools3.a spx
Takes you right to the download.
JimD.
http://www.mztools.com/v3/
Takes you right to the download.
JimD.
ASKER
I have MZ tool, but I dont how to use it for my situation
You can put something like this in a module:
Public Sub MyErrorHandler(Err As String)
MsgBox Err, vbCritical, "Error"
End Sub
Then call it from your error handling:
Private Sub Form_Load()
On Error GoTo HandleErr
ExitHere:
Exit Sub
HandleErr:
Call MyErrorHandler("Error# " & Err.Number & ": " & Err.Description)
Resume ExitHere
End Sub
Public Sub MyErrorHandler(Err As String)
MsgBox Err, vbCritical, "Error"
End Sub
Then call it from your error handling:
Private Sub Form_Load()
On Error GoTo HandleErr
ExitHere:
Exit Sub
HandleErr:
Call MyErrorHandler("Error# " & Err.Number & ": " & Err.Description)
Resume ExitHere
End Sub
<<I have MZ tool, but I dont how to use it for my situation>>
I could have sworn that MZ Tools had the capability to insert it into all modules, but it looks like it only works on a per procedure basis.
I may have been getting it confused with the VBA Error handler add-in which came with the Access 2000 Office Developer Edition, which does. But I can't find a download for that.
JimD.
I could have sworn that MZ Tools had the capability to insert it into all modules, but it looks like it only works on a per procedure basis.
I may have been getting it confused with the VBA Error handler add-in which came with the Access 2000 Office Developer Edition, which does. But I can't find a download for that.
JimD.
ASKER
DBDevl:
I m calling the procedure, but I should call that procedure in 70 forms. I need something speed up this process instead of opening 70 froms and calling that procedure.
I m calling the procedure, but I should call that procedure in 70 forms. I need something speed up this process instead of opening 70 froms and calling that procedure.
Yep I understand what you are saying now. Check out this link:
https://www.experts-exchange.com/questions/22438027/How-to-add-programmatically-VBA-code-to-an-Access-2003-module.html
https://www.experts-exchange.com/questions/22438027/How-to-add-programmatically-VBA-code-to-an-Access-2003-module.html
Sorry, but I cannot find any tool that will do an insert against an entire project or module except for the one included in the A2000 ODE.
JimD.
JimD.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes ... MZTools will only add an error template (that you have created) per procedure.
Of course, I'm sure you could write code to programatically insert code in every procedure ... but probably not that much fun, and would still require separate tweaking. Here is one example of an MZTool error template I created:
On Error GoTo {PROCEDURE_NAME}_Error
{PROCEDURE_NAME}_Exit:
On Error Resume Next
Err.Clear
'Cleanup here ....
docmd.Hourglass False
docmd.SetWarnings True
On Error GoTo 0
Exit {PROCEDURE_TYPE}
{PROCEDURE_NAME}_Error:
Call SEH_ErrProcess("Error", "Application execution error.", _
"An unexpected error has occurred.", _
"{MODULE_NAME}", "{PROCEDURE_NAME}", _
Err.Source, Err.Number, Err.Description, Err.LastDllError, _
"If the problem persists, please contact the application developer.")
Goto {PROCEDURE_NAME}_Exit
***
mx
Of course, I'm sure you could write code to programatically insert code in every procedure ... but probably not that much fun, and would still require separate tweaking. Here is one example of an MZTool error template I created:
On Error GoTo {PROCEDURE_NAME}_Error
{PROCEDURE_NAME}_Exit:
On Error Resume Next
Err.Clear
'Cleanup here ....
docmd.Hourglass False
docmd.SetWarnings True
On Error GoTo 0
Exit {PROCEDURE_TYPE}
{PROCEDURE_NAME}_Error:
Call SEH_ErrProcess("Error", "Application execution error.", _
"An unexpected error has occurred.", _
"{MODULE_NAME}", "{PROCEDURE_NAME}", _
Err.Source, Err.Number, Err.Description, Err.LastDllError, _
"If the problem persists, please contact the application developer.")
Goto {PROCEDURE_NAME}_Exit
***
mx
If you're wanting error handling across the board then you may have to fork out for it depending upon your needs.
Wayne Phillips has done some great, indepth work with the Global Error Handler here.
It far extends the ability of normal error handling, for example Iterating the Call Stack and more.
Cheers.
Wayne Phillips has done some great, indepth work with the Global Error Handler here.
It far extends the ability of normal error handling, for example Iterating the Call Stack and more.
Cheers.
www.mztools.com
JimD.