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
 

Some videos you may like

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

pjmatelli

Board Regular
Joined
Oct 13, 2005
Messages
206
I figured out my answer. I created a 'joined data' field and have my dlookup check that field and it works perfectly!
 

Watch MrExcel Video

Forum statistics

Threads
1,122,670
Messages
5,597,482
Members
414,144
Latest member
UDFNewbie

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
Top