validate field by entering number twice

  • Thread starter Thread starter Karen
  • Start date Start date
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?
 
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.
 
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
 
Back
Top