validate field by entering number twice

K

Karen

Hi,

I want to validate a serial number by having the number entered twice. If
the numbers do not match I want a message box to pop up alerting the user
that the numbers do not match.

I was thinking of something along the lines of using On Dirty on the second
field with the code IIf ([serialnumber_1]<>[serialnumber_2],
[forms]!frmMsgBox). But I can't get this to work. Any suggestions?
 
J

Jeff Boyce

Karen

For what purpose...?

Why are the users entering a serial number? Is this initial data entry, or
is this using the serial number to look something (else) up?

On Dirty, I suspect, pertains to the form ... take a look at AfterUpdate on
the control. (by the way, in forms in Access, they are "controls". in the
tables, they are "fields")

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
N

Nigel

Hi Karen,

Presuming this is for the original data entry check you could try something
like this. I'm using two Text Boxes - txtSerial and txtValidate:

Private Sub txtValidate_AfterUpdate()
If Me.txtSerial.Value = Me.txtValidate.Value Then
MsgBox ("Serial number validated!")
Else
MsgBox ("You mistyped the serial number. Please try again!")
Me.txtSerial.Value = Null
Me.txtValidate.Value = Null
End If
End Sub
 

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