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

HOW to trap ACCESS form errors?

Status
Not open for further replies.

euman

Programmer
Jan 2, 2002
32
GB
How do you trap what I might call "form-level" errors in Access 2000?

You have an Access 2000 form, as front end to your SQL database, containing related tables (say CUSTOMER and ORDER)

You do not want the user to be able to delete a Customer for whom Orders exist - and you set up database-level rules to achieve this.

When the user tries to delete a customer who has existing orders - you get a horrible SQL message that means they cannot do it.

PROBLEM: HOW do you trap this error condition and replace the SQL message with your own friendlier message? (Note: All the normal form EVENTs do not seem to be able to achieve this).
 
Actually, there is an event...Error event.

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Response = acDateErrContinue 'to get rid of the "horrible" message

Select Case DataErr
'DataErr has the error number that has occured
...
End Select
End Sub

[pipe]
Daniel Vlas
Systems Consultant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top