Validation rule -matching fields

P

pinksand

New to Access 2003. End results I am looking for. I want to set up a data
base so that when filling out the form in (1 field) enter account no. In (2
field) re-enter acct number.
My question: how do I set it up so that an error message populates when the
account number is re-enter and does not match. I have tried looking for the
right validation format, but have not had much success.
 
J

John Vinson

New to Access 2003. End results I am looking for. I want to set up a data
base so that when filling out the form in (1 field) enter account no. In (2
field) re-enter acct number.
My question: how do I set it up so that an error message populates when the
account number is re-enter and does not match. I have tried looking for the
right validation format, but have not had much success.

Rather than punishing the user if they misenter the account number,
might it not be better to provide them with a Combo Box listing the
valid account numbers so they can just select one?

That said... you can use *three* textboxes on your form; the first two
would be labeled "Enter account no:" and "Reenter account no:". The
third would be actually bound to the account number field in your
table, and should probably be set with its Visible property set to No.

In the AfterUpdate event of the other two textboxes you would put code
like

Private Sub txtAcctno1_AfterUpdate()
If IsNull(Me!txtAcctno1) Or IsNull(Me!txtAcctno2)
Then
Exit Sub
Else
If Me!txtAcctno1 <> Me!txtAcctno2) Then
MsgBox "Please reenter, these do not match"
Me!txtAcctno2.Undo
Else
Me!txtAcctno = Me!txtAcctno1
End If
End If
End Sub

John W. Vinson[MVP]
 
P

pinksand

Because the account number is unknown. When a caller calls in they will
provide us with the number. It would be one of millions and it would not be
beneficial to list all the numbers. We need the caller to provide us with
that number.
any other suggestions would be highly appreciated...
 
J

John Vinson

Because the account number is unknown. When a caller calls in they will
provide us with the number. It would be one of millions and it would not be
beneficial to list all the numbers. We need the caller to provide us with
that number.
any other suggestions would be highly appreciated...

How about the other suggestion that I already posted:


John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top