View Full Version : Error handling..


wh00t
05-15-2002, 02:16 AM
Hi

I have an on error event for a run time error which occurs


Private Sub Form_Error(DataErr As Integer, Response As Integer)

Const conErrFieldRequired = 2427

If DataErr = conErrFieldRequired Then
DSPMSG "This is not a valid Customer Code, please check the number and try again."
Response = acDataErrContinue
Else
Response = acDataErrDisplay
End If
End Sub


but this is not working, the run time error still occurs, any ideas?


EDIT - the DSPMSG part, is a public function for displaying messages

[This message has been edited by wh00t (edited 05-15-2002).]

The_Doc_Man
05-15-2002, 11:16 AM
Possibly the error has to be associated with the control rather than the entire form? Just a guess.

wh00t
05-16-2002, 04:02 AM
here's what I am now using, this is in the OnExit event for the field

On Error GoTo Err_CustCode_Exit

Const conErrNotInList = 2427

Other Code Here

Err_CustCode_Exit:
If Err.Number = conErrNotInList Then
DSPMSG "This is not a valid Customer Code, please check the number and try again."
Else
DSPMSG Err.Description
End If


this works, thanks for the suggestion