By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,483 Members | 1,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,483 IT Pros & Developers. It's quick & easy.

Need Help With duplicates warning Message box

P: 1
Hello,
I am not great with coding but I am trying to run code in the before update event procedure on a form to make sure that there isnt already a record that matches the current entry. My Table Name is NEW TRAUMA INSTS and form name is ORDER TRAUMA INSTS, which has a different table as its control source here is the code that I have managed to come up with and it seems to work other than it returns the warning message when there is any value in the field in table NEW TRAUMA INSTS not just a duplicate value:

Private Sub Combo9_BeforeUpdate(Cancel As Integer)
Dim rslt As Integer

If Nz(DLookup("[Catalog Number]", "[NEW TRAUMA INSTS]", "[Catalog Number]= '" & Me.[Catalog Number] & "'"), 0) <> 0 Then
rslt = MsgBox("THIS ITEM IS PENDING ORDER. Do you wish to continue?", vbYesNo)
If rslt = vbNo Then Me.Undo
Cancel = False
If rslt = vbYes Then DoCmd.Save

End If


End Sub

what I really want this to do is search the table for a matching entry and warn the user that there is already a matching entry, with a message box where yes allows continue and no deletes current record, both my yes and no selections work as I want but like I said the warning message is being shown when there is any record in field catalog number not just a duplicate
any help would be greatly appreciated
Aug 5 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.