Let me thank you in advance for you help.
I have a ComboBox that shows Detail records. When one record is selected, it is loaded to the PODetail Table.
I want to prevent a duplicate selection of a ComboBox record.
I’m trying to use a Dlookup in the AfterUpdate Event of the ComboBox in the Control Source PODetailItem to see if the selected Data is already in the Table. If so, I’ll Undo the selection and send the user a message that the record is already been used.
The fields I’m looking to use for the Dlookup on the Table are ‘PODetailItem’, ‘POID’ and ‘POdetailJobID’.
PODetailItem is (Text), POID is (Number), PODetailJobID is (Number)
The User recognizes what they want to select off the ComboBox by ‘PODetailItem’, which is unique Data.
I have tried every combination of Dlookup syntax that I could think of, to get it to work, but I not been able to do it. If someone can tell me where I’m going wrong, I would very grateful.
I can get it to work using 1 criteria, but once I add an And Condition, it will not work.
This is just one variation that I tried. I have run a lot of them and I hope this is the one that does return False although I don't think it matters because none of them worked.
Dim CheckForItem As String
Dim CheckForPOID As Integer
Dim CheckForJobID As Integer
Dim stLinkCriteria As String
stLinkCriteria = "[PODetailItem] = " & "'" & CheckForItem & "' And [PODetailJobID] " = "& [CheckForJobID]& " And [POID] = " & [CheckForPOID] & " '"
When I run this version it returns stLinkCriteria, with a value of False.
I have run it other ways and get the correct values, but I get a Mismatch as well as other errors when going through the Dlookup code below.
If Me.PODetailItemID.Column(1) = DLookup("[PODetailItem]", "tblPODetail", stLinkCriteria) Then
MsgBox " Etc”
Me.Undo
End If
Again, thank you for your help!
I have a ComboBox that shows Detail records. When one record is selected, it is loaded to the PODetail Table.
I want to prevent a duplicate selection of a ComboBox record.
I’m trying to use a Dlookup in the AfterUpdate Event of the ComboBox in the Control Source PODetailItem to see if the selected Data is already in the Table. If so, I’ll Undo the selection and send the user a message that the record is already been used.
The fields I’m looking to use for the Dlookup on the Table are ‘PODetailItem’, ‘POID’ and ‘POdetailJobID’.
PODetailItem is (Text), POID is (Number), PODetailJobID is (Number)
The User recognizes what they want to select off the ComboBox by ‘PODetailItem’, which is unique Data.
I have tried every combination of Dlookup syntax that I could think of, to get it to work, but I not been able to do it. If someone can tell me where I’m going wrong, I would very grateful.
I can get it to work using 1 criteria, but once I add an And Condition, it will not work.
This is just one variation that I tried. I have run a lot of them and I hope this is the one that does return False although I don't think it matters because none of them worked.
Dim CheckForItem As String
Dim CheckForPOID As Integer
Dim CheckForJobID As Integer
Dim stLinkCriteria As String
stLinkCriteria = "[PODetailItem] = " & "'" & CheckForItem & "' And [PODetailJobID] " = "& [CheckForJobID]& " And [POID] = " & [CheckForPOID] & " '"
When I run this version it returns stLinkCriteria, with a value of False.
I have run it other ways and get the correct values, but I get a Mismatch as well as other errors when going through the Dlookup code below.
If Me.PODetailItemID.Column(1) = DLookup("[PODetailItem]", "tblPODetail", stLinkCriteria) Then
MsgBox " Etc”
Me.Undo
End If
Again, thank you for your help!