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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Run-Time Errors in Forms

Status
Not open for further replies.

mas5

Programmer
Dec 15, 2002
98
0
0
US
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

If Not IsNull(Me.SchoolStaffCodeID) And IsNull(Me.SortPriority) Then
Cancel = True
Call InfoMessage(13)
End If

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 within the specific field and not in the form?

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 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. Thanks in advance.
 
I used to have problems with null values also, I always use
isnull(variable) = true or isnull(variable) = false now, cuts down on the dodgy not isnull's.

:)
Abig99
 
I'm not having problems with the isnull part. That works fine. It's trapping other errors that doesn't work as I expected - like entering character data into numeric fields.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top