I have a form to input new contacts. The form has a text box for the entry of a Id# for the contact. What I want to do is check this ID# and if it already exists, let the user know and clear out the text box and return to the textbox for rentry of the correct ID#. For some reason I can't get the textbox to clear... Here is the code I am using
Private Sub txtCDCNum_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[CDCNum]", "tblInmates", "[CDCNum]= '" & StrConv(txtCDCNum, vbUpperCase) & "'")) Then
Me.txtCDCNum.Undo '**<-- This doesn't clear textbox
Cancel = True
MsgBox "This CDC Number already exists. Please enter a new CDC Number.", vbOKOnly, "Duplicate CDC Number"
End If
End Sub
Any suggestions?
Private Sub txtCDCNum_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[CDCNum]", "tblInmates", "[CDCNum]= '" & StrConv(txtCDCNum, vbUpperCase) & "'")) Then
Me.txtCDCNum.Undo '**<-- This doesn't clear textbox
Cancel = True
MsgBox "This CDC Number already exists. Please enter a new CDC Number.", vbOKOnly, "Duplicate CDC Number"
End If
End Sub
Any suggestions?