My Assistant
![]() ![]() |
|
|
Jul 28 2006, 03:04 PM
Post
#1
|
|
|
New Member Posts: 7 From: Roanoke VA |
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 |
|
|
|
Jul 28 2006, 03:14 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 20,228 From: Colorado |
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 |
|
|
|
Jul 28 2006, 03:58 PM
Post
#3
|
|
|
UtterAccess VIP Posts: 5,283 From: Upstate NY, USA |
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. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th June 2013 - 09:33 AM |