Duplicates error message

David b

Registered User.
Local time
Today, 23:59
Joined
Mar 2, 2003
Messages
102
I have a form with a list box. Double clicking a record sends that recordno to a table. I have the table set to no duplicates to prevent the same record being sent twice. If a duplicate is sent the confusing (for the user) standard access message appears - Access can`t append all records in the append query etc etc.

How do I make a clearer error message for this situation ?
TIA
David b
 
You should place some error handling code in your form. Below is some code for basic error handling. Note the use of Err.Number and Err.Description. I don't know what the error number is for your error, but you can test out the procedure and find it. Then you can put some If...Then code to trap the error of having duplicates and display a more informative message with instructions on what to do.
Code:
Private Sub lstbox_DblClick(Cancel As Integer)
On Error GoTo Err_lstbox_DblClick

    'place your code here

Exit_lstbox_DblClick:
Exit Sub

Err_lstbox_DblClick:
    MsgBox "An error has occurred!" & vbCrLf & _
    "The error code is : " & Err.Number & vbCrLf & _
        "The error description is : " & Err.Description
    Resume Exit_lstbox_DblClick

End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom