pjmatelli
Board Regular
- Joined
- Oct 13, 2005
- Messages
- 206
Hi All,
I am using the following code to find out if an item has already been entered on a PO. It works, but for ALL POs. This code will only allow me to order any item once - no matter what the PO # is. I need it to check for the Item # and PO# combination. Also, I can't seem to find the code to delete the current record. Any advice??? Thanks so much!
Private Sub Item___BeforeUpdate(Cancel As Integer)
If Me.[Item #] = DLookup("[Item #]", "[tblPOTransDetail]", "[Item #] = form![Item #]") _
And Me.[PO#] = DLookup("[PO#]", "[tblPOTransDetail]", "[PO#] = form![PO#]") Then
MsgBox "You have already ordered that item on this PO!", , "Repeated Item!"
DoCmd.CancelEvent
'***Delete Current Record***
End If
End Sub
I am using the following code to find out if an item has already been entered on a PO. It works, but for ALL POs. This code will only allow me to order any item once - no matter what the PO # is. I need it to check for the Item # and PO# combination. Also, I can't seem to find the code to delete the current record. Any advice??? Thanks so much!
Private Sub Item___BeforeUpdate(Cancel As Integer)
If Me.[Item #] = DLookup("[Item #]", "[tblPOTransDetail]", "[Item #] = form![Item #]") _
And Me.[PO#] = DLookup("[PO#]", "[tblPOTransDetail]", "[PO#] = form![PO#]") Then
MsgBox "You have already ordered that item on this PO!", , "Repeated Item!"
DoCmd.CancelEvent
'***Delete Current Record***
End If
End Sub