Good day All,
I created an If statement in a New Record button to check if the new entry is a duplicate, if its unique then it allow the record to be saved. If the new record is a duplicate it will not add the new entry.
Unfortunately it seems to be allowing the entry. I thought i had it right, but further testing has proven me wrong.
So the first part of the code is to run the query to find a duplicate(works fine). The message box appears if a duplicate is found, but i am unable to figure out how to have it STOP the New Record action.
I know the answer is simple but cant get my head around what i need to enter.
I created an If statement in a New Record button to check if the new entry is a duplicate, if its unique then it allow the record to be saved. If the new record is a duplicate it will not add the new entry.
Unfortunately it seems to be allowing the entry. I thought i had it right, but further testing has proven me wrong.
Code:
'Find Duplicate Value
DoCmd.OpenQuery "qryDuplicateRequest", acViewNormal, acReadOnly
If (DCount("*", "qryDuplicateRequest") = 0) Then
DoCmd.GoToRecord acForm, "frmRequest", acNewRec
Else
Beep
MsgBox "Currently in process. Please contact Inventory Managment", vbExclamation, "Count already Requested"
Exit Sub
End If
DoCmd.Close acQuery, "qryDuplicateRequest"
Me.Refresh
So the first part of the code is to run the query to find a duplicate(works fine). The message box appears if a duplicate is found, but i am unable to figure out how to have it STOP the New Record action.
I know the answer is simple but cant get my head around what i need to enter.