I have a form and subform. Reservations, and Reservation_Details. Reservation details is where I add my items to be reserved. I want to pop up a message and undo an entry if it already exists in the subform. I am using this code:
My problem is with the DLookup statement. I need it to select entries where [BOMNumber] = '" & Me.cboBOMDescription.Column(0) & "' and [ReservationID] = " & [Forms].[frmreservations].[TxtReservationID] & "'").
I know that this is written completely wrong and am hoping I can get some help with this statement.
THanks
Code:
'Custom error message if you are creating duplicates
Dim Answer As Variant
Answer = DLookup("[BOMNumber]", "tblReservation_Details", "[BOMNumber] = '" & Me.cboBOMDescription.Column(0) & "' and [ReservationID] = " & [Forms].[frmreservations].[TxtReservationID] & "'")
If Not IsNull(Answer) Then
MsgBox "Duplicate Social Security Number Found" & vbCrLf & "Please enter again.", vbCritical + vbOKOnly + vbDefaultButton1, "Duplicate"
'Cancel = True
Me.cboBOMDescription.Undo
Else
End If
My problem is with the DLookup statement. I need it to select entries where [BOMNumber] = '" & Me.cboBOMDescription.Column(0) & "' and [ReservationID] = " & [Forms].[frmreservations].[TxtReservationID] & "'").
I know that this is written completely wrong and am hoping I can get some help with this statement.
THanks