I have a form with several tables. One table (SerialTest) has a field (SerialNumber) that the operators select a serial number from a list. I need to check another field (Serial_Number) on a different table (OpenAlert) to make sure that the serial number is not in that field. If it is in the second table then pop up a message " serial number is all ready open" , with an OK button and then allow entry.
I know I need to use Before update on the SerialNumber field on the SerialTest table but I am not sure what is wrong with my entry. Here is what I have now.
The serial numbers in the list contain alpha and numeric characters.
I know I need to use Before update on the SerialNumber field on the SerialTest table but I am not sure what is wrong with my entry. Here is what I have now.
Code:
Private Sub SerialNumber_BeforeUpdate(Cancel As Integer)
If DLookup("*", "OpenAlert", "[Serial_Number]=#" & Me.SerialNumber & "#") > 0 Then
MsgBox "This already exists", vbExclamation, "Record Exists"
Cancel = True
Me.SerialNumber.Undo
End If
End Sub
The serial numbers in the list contain alpha and numeric characters.