Removing VB popup Box

  • Thread starter Thread starter Anil
  • Start date Start date
A

Anil

Hi,
Just wanted to know, how do you remove the VB popup box that appear
when an error in the code occurs? I would rather like to create my ow
popup box that can direct users to closing that form.

thanks in advance

Ani
 
Hi:

Try using the Form_Error event.

Here DataErr is err number to trap and you can replace Access error message
with yours and then set Response to acDataErrContinue which prevents
Access's default error message from popping up.


Private Sub Form_Error(DataErr As Integer, Response As Integer)
Const conDuplicateKey = 3022
Dim strMsg As String

If DataErr = conDuplicateKey Then
Response = acDataErrContinue
strMsg = "Each employee record must have a unique " _
& "employee ID number. Please recheck your data."
MsgBox strMsg
End If
End Sub

Regards,

Naresh Nichani
Microsoft Access MVP
 
Back
Top