I've always found that errors crop up where I have noted that they can not possibly do so.
Often it is the user but not always
as a result I developed this little fella (used most recently in an access app) to handle errors and work out what I should do for me.
Code:'The no error can possibly happen here (multi)error handler 'recomend 'for each module, form etc Public temp 'then use private sub mysub() on error goto err1: 'your code goes here exit sub err1: temp=errme(err.Source, err.Number , err.Description) 'how you deal with these terrable errors is up to you. end sub 'Put this in a module Public Static Function ErrMe(sss, num, desc As Variant) 'This sub is for use in errors should never happen and related code On Error GoTo error_in_error Dim lastnum As Variant Dim PassFac Dim ErrLv Dim LastLv ErrLv = 0 If lastnum = num Then ErrLv = ErrLv + LastLv msgbox "ERROR(" & ErrLv & " in " & sss & " | " & num & ": " & desc GoTo ByPassMe 'skip the multi error handler error_in_error: 'loop point for errors within errors ErrLv = ErrLv + 1 'counts the extras as well On Error GoTo error_in_error 'if that causes more errors loop again PassFac = ErrLv PassFac = 71 + (((PassFac + 1) * 13) / 9) msgbox "ALERT - Errors within errors reported. " & PassFac & "% chance of user input error" ByPassMe: 'this ends the multi error handler '------------------------------------------------------------- ' The ErrMe Error Code Set '------------------------------------------------------------- 'Number 0 1 2 3 4 '------------------------------------------------------------- 'Can recover N Y Y Y Y 'recover by resume next . Y N/Y N N 'recover by do next bit . . Y Y N 'recover by exit sub . . Y Y Y '------------------------------------------------------------- ErrLv = ErrLv + 1 LastLv = ErrLv If ErrLv > 4 Then ErrLv = 0 'if we had more than 4 then we report 'that it is time to say good buy If ErrLv = 0 Then msgbox "Unable to handle errors" ErrMe = ErrLv 'time to return our findings End Function





Reply With Quote