Full Version: simple data entry form with 2 text boxes/same field entered, 2nd
UtterAccess Discussion Forums > Microsoft® Access > Access Q and A
cfvernon
I have designed a very simple access form so that a user can enter subscriber ids. I need to force the user to validate the entry and I chose the simple method of typing the id into 2 text boxes, much like the validation when you change your password. I am having difficulty coding for the situation where the user miskeys the id in the 2nd box. I am coding a procedure on the enter event of the 2nd box (confirm) to display an error msgbox when the miskey is recognized (idtxt.value <> confirmtxt.value). After entering the first id, the cursor returns to the 1st box, but the text remains in the 2nd box, which causes the error msgbox to pop up when tabbing from the 1st box with the new id. Am I going about this the wrong way...can I accomplish the same thing using a macro ? It has been over 5 years since my VB class and unfortunately I never got the chance to use the knowledge, so I'm more than a little rusty.

Thanks for any help. I have copied my code below. Confirmtxt is the 2nd box.


Private Sub Confirmtxt_Enter()
Dim LResponse As Integer

If (IDtxt.Value <> Confirmtxt.Value) And (Confirmtxt.Value <> "") Then
LResponse = MsgBox("Id# Mismatch")
End If

If LResponse = vbOK Then
Confirmtxt.Text = ""
Confirmtxt.SetFocus
Exit Sub
End If

If Confirmtxt.Value = "" Then
MsgBox ("Id# Must Be Confirmed")
Confirmtxt.Text = ""
Confirmtxt.SetFocus
End If

Confirmtxt.Text = ""

End Sub
strive4peace
Hi,

use the AfterUpdate event of the confirm control to verify

if it doesn't match, then clear one or both controls

me.controlname = null
ace
Assuming your form is bound to a data source put your test in the
BeforeUpdate event of the form and set the Cancel argument to
true if the entries don't match.

Take in to consideration that a simple cut and paste makes
the whole process a waste of time.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.