Hi, my form has a textbox (txt_PIN), when the text box is updated i want to check the user table to see if it already exists. I keep getting errors, i think itt is because of the way the numerical value is being referenced?
Private Sub txt_PIN_AfterUpdate()
Dim PIN As Integer
Dim stLinkCriteria As Integer
PIN = Me.txt_PIN.Value
stLinkCriteria = "[PIN]= " & "'" & Me.txt_PIN & "'"
If Me.txt_PIN = DLookup("[PIN]", "tbl_users", stLinkCriteria) Then
MsgBox "The PIN, " & txt_PIN & ", already exists in database." _
& vbCr & vbCr & "Please choose an alternative username", vbInformation, "Warning"
Me.Undo
Me.txt_PIN.Value = ""
Me.txt_PIN.SetFocus
End If
End Sub
Private Sub txt_PIN_AfterUpdate()
Dim PIN As Integer
Dim stLinkCriteria As Integer
PIN = Me.txt_PIN.Value
stLinkCriteria = "[PIN]= " & "'" & Me.txt_PIN & "'"
If Me.txt_PIN = DLookup("[PIN]", "tbl_users", stLinkCriteria) Then
MsgBox "The PIN, " & txt_PIN & ", already exists in database." _
& vbCr & vbCr & "Please choose an alternative username", vbInformation, "Warning"
Me.Undo
Me.txt_PIN.Value = ""
Me.txt_PIN.SetFocus
End If
End Sub
Last edited: