Clear text box

poporacer

Registered User.
Local time
Today, 02:22
Joined
Aug 30, 2007
Messages
136
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?
 
Thanks Pete, but in the before update event you can't assign a variable so it doesn't work
 
oo - good point - didn't see that. Have you tried it after the Cancel = True point or does the same apply?
 

Users who are viewing this thread

Back
Top Bottom