I'm using the following code to lookup if a number already exists. Works fine.
I would like it to search in three other fields as well. Msamplenumber2, Msamplenumber3, Msamplenumber4
So when it does a lookup, it would look in all four fields. How can I combine those extra three fields below?
Or maybe there is a better way?
Private Sub Msamplenumber1_BeforeUpdate(Cancel As Integer)
Dim lngLookup1 As Variant
lngLookup1 = DLookup("[Msamplenumber1]", "Main", "[Msamplenumber1] = '" & Me![Msamplenumber1] & "'")
If lngLookup1 = Me![Msamplenumber1] Then
MsgBox Me![Msamplenumber1] & " - This Sample ID Already Exists!!!"
Cancel = True
End If
End Sub
I would like it to search in three other fields as well. Msamplenumber2, Msamplenumber3, Msamplenumber4
So when it does a lookup, it would look in all four fields. How can I combine those extra three fields below?
Or maybe there is a better way?
Private Sub Msamplenumber1_BeforeUpdate(Cancel As Integer)
Dim lngLookup1 As Variant
lngLookup1 = DLookup("[Msamplenumber1]", "Main", "[Msamplenumber1] = '" & Me![Msamplenumber1] & "'")
If lngLookup1 = Me![Msamplenumber1] Then
MsgBox Me![Msamplenumber1] & " - This Sample ID Already Exists!!!"
Cancel = True
End If
End Sub