I have a form After Update event for a field that checks to see if a Supplier Ref has been used before. If so, it alerts the user of a duplicate entry.
But what I need the code to do is to check the Supplier Ref against the SupplierID for that record. If the duplicate Supplier Ref was not used for the same SupplierID then go ahead and allow the user to enter the Supplier Ref. If the Supplier Ref was previously used for the same SupplierID Then alert the user of a duplicate entry.
Private Sub SupplierRef_AfterUpdate()
Dim SupplierRef As Variant
SupplierRef = DLookup("[BoughtInChargeID]", "Bought In Charges", "[SupplierRef] = Forms![Bought In Charges]![SupplierRef]")
If Not IsNull(SupplierRef) Then
MsgBox "A bought in charge invoice "
Me.SupplierRef.SetFocus
Me.SupplierRef = ""
End If
End Sub
Fields in the Bought In Charges Table:
BoughtInChargeID
SupplierRef
SupplierID
etc..
Any help would be appreciated....
But what I need the code to do is to check the Supplier Ref against the SupplierID for that record. If the duplicate Supplier Ref was not used for the same SupplierID then go ahead and allow the user to enter the Supplier Ref. If the Supplier Ref was previously used for the same SupplierID Then alert the user of a duplicate entry.
Private Sub SupplierRef_AfterUpdate()
Dim SupplierRef As Variant
SupplierRef = DLookup("[BoughtInChargeID]", "Bought In Charges", "[SupplierRef] = Forms![Bought In Charges]![SupplierRef]")
If Not IsNull(SupplierRef) Then
MsgBox "A bought in charge invoice "
Me.SupplierRef.SetFocus
Me.SupplierRef = ""
End If
End Sub
Fields in the Bought In Charges Table:
BoughtInChargeID
SupplierRef
SupplierID
etc..
Any help would be appreciated....