Duplicate key error message 
Author Message
 Duplicate key error message

On a form when I execute 4 queries which adds a record  
and record information to tables it is possible to
duplicate a primary key resulting in an error rejecting
the record.  I want to display a message that the record
did not get added due to the duplicate key.  I use
the "setwarnings false" to suppress the query warnings but
it also suppresses the query errors(I don't like the error
description anyway and want to use my own).   Below is the
code I am using.  Can anyone help me.

Thanks

Jim

ivate Sub Command168_Click()
On Error GoTo Err_Command168_Click
' Client Intake update MRS#
    Dim stDocName As String

    DoCmd.SetWarnings False

    stDocName = "Client Intake Append to Client Info"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

    stDocName = "Client Intake update MRS#"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

    Me.SocialSecurityNumber.Requery
    stDocName = "Client Intake Add SS to Internal Acts"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

    stDocName = "Client Intake update Client Info"
    DoCmd.OpenQuery stDocName, acNormal, acEdit
    DoCmd.SetWarnings True

Exit_Command168_Click:

    Exit Sub

Err_Command168_Click:
    MsgBox "This client could not be added due to a
duplicate SS#"
    'Resume Exit_Command168_Click

End Sub



Mon, 05 Dec 2005 02:50:27 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Trapping Duplicate Index/Key Errors (Old Message dissappeared)

2. No error message received on duplicate primary keys

3. duplicate key message

4. Message for duplicate key before saving

5. primary key duplicate message

6. Primary key duplicate value message

7. Custom "Duplicate Key Field" Message

8. duplicate primary key error handling

9. Trapping a Duplicate Key Error

10. Not Getting a Duplicate Primary Key Error


 
Powered by phpBB® Forum Software © phpBB Group