Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace/Delete Error Handling in All Subs 1

Status
Not open for further replies.

SeadnaS

Programmer
May 30, 2011
214
Hi folks,

I have a large Access 2003 database with a lot of forms and I am implementing an error logging system based on a code module i found online. The module checks all of the forms subs/functions to see if there is error handling and if there is none it inserts error handling code into them. The error handling code I wrote calls another module which logs the error to a table in the database.

The problem is that there are so many subs in the project that already have error handling. I need to delete the error handling from these so that I can implement the new error handling code instead.

I could do it manually but there is so much code here it would be an unbearable long and tedious task. I need either an Add-in or some code to run in the immediate window to go in and find the error handling code of each sub and delete it or replace it with my error handling.

If anyone could provide some help it would be much appreciated.

Regards,

SeadnaS.
 
The module checks all of the forms subs/functions to see if there is error handling and if there is none it inserts error handling code into them
Can't you adapt this module to do what you want ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV no i can't. I'd love to know what to change but I don't. I've been searching all over the net for help on the issue as I'm not familiar enough with VBA to do this. I understand how the module works but i don't know how to change it to get it to do what I want.

Remou I have mz tools 3 and it does not do this. I does error handling but it cannot go through all of the project code and delete or replace all of the error handling unfortunately. Still a very useful add-in though.

Thanks for the responses guys.
 
That looks great. How would I modify it to chop out the error handling from my procs? Obviously when the procedure name is mentioned it will be different for different procedures. So is it possible for it to find the error handling code when it will have different procedure names for each procedure?

This is what they look like:

Private Sub Command76_Click()
DoCmd.SetWarnings False: On Error GoTo Err_Command76_Click

[PROCEDURE_BODY]

Exit_Command76_Click:
Exit Sub

Err_Command76_Click:
Call ErrorLog(Err, Error$, Err.Source, Me.NAME, Erl)
Resume Exit_Command76_Click

End Sub
 
So every time it finds a line with "On Error..." i want it to delete that line and every time it finds "Exit_...:" it deletes that line and everything below that line before end sub or end function. I just don't know how to code that.
 
How do I run the code?

Main("Database Path","?")
 
I'm having a problem. I changed a line of code to match a line in some of the error handlers. Your original code works great but when I made this change to it it did nothing.

This is your original code on line 33:

''The list returned is of modules containing this line
sFind = "On Error GoTo Err_" & ProcArray(1, i)

This is what I changed it to:

''The list returned is of modules containing this line
sFind = "On Error GoTo " & ProcArray(1, i) & "_Err:"

Is there something i'm doing incorrectly?
 
The code is quite sketchy, so lines may appear more than once. In this case, the find line also occurs in the procedure GetErrProcs(oVBE, ProcArray). Did you change your line in both places?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top