I'm having a heck of a time with error trapping. Here's my situation and what I've done:
I have a numeric field. If the user enters a character in the field I try to trap it in the on exist event of the field as follows:
Private Sub SortPriority_Exit(Cancel As Integer)
On Error GoTo SortPriority_Err
'Code not related to error processing here
Exit_SortPriority:
Exit Sub
SortPriority_Err:
If IsNumeric(Me.SortPriority) = False Then
Cancel = True
Call InfoMessage(13)
Resume Exit_SortPriority
End If
End Sub
The above code does not trap the error. Instead the On Error event of my form traps the error. The code for this event is below:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Call ErrorTrap(DataErr, "on error", "subschoolstaffcodes1", ErrorAction)
If ErrorAction = 0 Then
'what are the proper codes for the response?
End If
end sub
My ErrorTrap routine writes to an error table and looks up the error in another table that notes what should happen next. If erroraction = 0 = resume, 1=resume next, 2 = quit, etc. (I'm still working on this.)
I have several questions.
First, is there a way I can trap my error at the field level and not at the form level?
Second, sometimes I'm glad I can trap the error on the form level, but I have no idea what code to set Response to if I want to Resume, Resume Next, etc. Is it 0 or 1 or 2 or 3 or what? I'd like to be able to force error processing to execute the code in my on exist event.
Third, when I disable my error processing I get an error message from access: 2113 with a message "The value entered for this field isn't valid, etc." When I try to raise error 2113 the err.description I get is application error. How can I get the description that access gave me when I didn't trap the error?
Can anyone help? I've tried Access Help to no avail. I've read manuals. I've done keywork searches in these forums and have not found what I'm looking for. Thanks in advance.
I have a numeric field. If the user enters a character in the field I try to trap it in the on exist event of the field as follows:
Private Sub SortPriority_Exit(Cancel As Integer)
On Error GoTo SortPriority_Err
'Code not related to error processing here
Exit_SortPriority:
Exit Sub
SortPriority_Err:
If IsNumeric(Me.SortPriority) = False Then
Cancel = True
Call InfoMessage(13)
Resume Exit_SortPriority
End If
End Sub
The above code does not trap the error. Instead the On Error event of my form traps the error. The code for this event is below:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Call ErrorTrap(DataErr, "on error", "subschoolstaffcodes1", ErrorAction)
If ErrorAction = 0 Then
'what are the proper codes for the response?
End If
end sub
My ErrorTrap routine writes to an error table and looks up the error in another table that notes what should happen next. If erroraction = 0 = resume, 1=resume next, 2 = quit, etc. (I'm still working on this.)
I have several questions.
First, is there a way I can trap my error at the field level and not at the form level?
Second, sometimes I'm glad I can trap the error on the form level, but I have no idea what code to set Response to if I want to Resume, Resume Next, etc. Is it 0 or 1 or 2 or 3 or what? I'd like to be able to force error processing to execute the code in my on exist event.
Third, when I disable my error processing I get an error message from access: 2113 with a message "The value entered for this field isn't valid, etc." When I try to raise error 2113 the err.description I get is application error. How can I get the description that access gave me when I didn't trap the error?
Can anyone help? I've tried Access Help to no avail. I've read manuals. I've done keywork searches in these forums and have not found what I'm looking for. Thanks in advance.