Hello.
For a while I have been using the following code to call a sub and e-mail me all information about the errors that my db users encounter:
This has been working well (that I know) so far, however today I was tweaking the code in a form and I happened to open the form directly to run some tests instead of doing it through another form. In any case, I noticed that when opening the form directly I get an error (which is expected because the code cannot perform some of the tasks it is requested to perform). This is "Runtime Error 2474. The expression you entered requires the control to be in the active window". As I say, this error is expected becasue the form was opened directly and it happens here:
My issue is that the error sub is in itself creating an error and when this happens, the code halts and this error is not getting recorded and it is not e-mailed to me.
I wonder now if there may be other instances where this may also happen and I am not aware of them.
How can the error sub be bullet-proofed?
Thanks
mafhobb
For a while I have been using the following code to call a sub and e-mail me all information about the errors that my db users encounter:
Code:
Form_Load_Error:
Dim ErrorForm As String
Dim ErrorControl As String
Dim ErrorCode As String
Dim ErrorNumber As String
ErrorForm = Nz(Screen.ActiveForm.Name, "No Form Loaded")
ErrorControl = Nz(Screen.ActiveControl.Name, "No Control Loaded")
ErrorNumber = Err.Number
ErrorCode = Err.Description
Call SendError(ErrorCode, ErrorNumber, ErrorControl, ErrorForm)
Exit Sub
This has been working well (that I know) so far, however today I was tweaking the code in a form and I happened to open the form directly to run some tests instead of doing it through another form. In any case, I noticed that when opening the form directly I get an error (which is expected because the code cannot perform some of the tasks it is requested to perform). This is "Runtime Error 2474. The expression you entered requires the control to be in the active window". As I say, this error is expected becasue the form was opened directly and it happens here:
Code:
ErrorControl = Nz(Screen.ActiveControl.Name, "No Control Loaded")
My issue is that the error sub is in itself creating an error and when this happens, the code halts and this error is not getting recorded and it is not e-mailed to me.
I wonder now if there may be other instances where this may also happen and I am not aware of them.
How can the error sub be bullet-proofed?
Thanks
mafhobb