I'm using the following code to check if a number exists. How can I change it so it looks in the other fields too?
Other fields: Msamplenumber2, Msamplenumber3 and Msamplenumber4
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 Number Already Exists!!!"
Cancel = True
End If
End Sub
Other fields: Msamplenumber2, Msamplenumber3 and Msamplenumber4
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 Number Already Exists!!!"
Cancel = True
End If
End Sub