Saving Duplicate ID Causes Runtime Error

jleval

Registered User.
Local time
Today, 03:40
Joined
May 16, 2012
Messages
53
My form has a command button to allow me to save a record. Whenever I save a duplicate record I get a runtime error that throws me into debug mode. How can I keep this from happening and perhaps just have a standard, "you cant save this record because it will cause a duplicate"?
 
Never mind guys, I used the following code on the after update event to check for duplicates in the table.

If Not IsNull(DLookup("[PartNumber]", "CutterToolSpecs", "[PartNumber] = '" & Me.PartNumber & "'")) Then
MsgBox "Duplicate Tool Number! Must Add A Differant Part Number"
DoCmd.GoToControl ("PartNumber")

End If
 
Hopefully you used the correct spelling in your code and your post is just a typo.
"Different"

I work with applications that contain spelling mistakes and it is not a good look.
One of them has fields in one table spelled correctly but wrong in another. It makes for rather silly looking SQL that is easy to get wrong.

ON A.PRIVILEGE = B.PRIVELEDGE
 
Thanks but were would you suggest I place this code?
 
Yah, it was a tipo in the code above. In my program it is corect.
 
Yah, it was a tipo in the code above. In my program it is corect. I apriciate ur help. :)

Hopefully you used the correct spelling in your code and your post is just a typo.
"Different"

I work with applications that contain spelling mistakes and it is not a good look.
One of them has fields in one table spelled correctly but wrong in another. It makes for rather silly looking SQL that is easy to get wrong.

ON A.PRIVILEGE = B.PRIVELEDGE
 

Users who are viewing this thread

Back
Top Bottom