Dlookup - Multiple Items

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
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I figured out my answer. I created a 'joined data' field and have my dlookup check that field and it works perfectly!
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,438
Members
448,897
Latest member
dukenia71

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top