Verifying data entry

  • Thread starter Thread starter laura.dodge
  • Start date Start date
L

laura.dodge

Hi, I am trying to figure out a way to verify a piece of data entry.
Study ID is in the form of two letters and three numbers (I'm using
the input mask <LL000;). The first letter will be 'm' for male or 'f'
for female, and the second letter will be 'c' for case and 'x' for
control. There is a separate field for case or control, and boss wants
to make sure that the code matches the case/control field. Can anyone
help me code a macro to check this? Thanks!
 
Take a look at the BeforeUpdate event for the record. That would be a good
place to do this kind of validation checking.

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.
 
Laura -

In the BeforeUpdate event, place code like this:

If Mid(Me.[Study ID],2,1) <> Me.CaseControlField Then
msgbox("Study ID does not have the correct case/control value")
Cancel = True
End If

The field names will need to be what you have on the form. You can put
whatever in the msgbox you want the user to see. The Cancel will cause the
record not to be written.
 
Laura -

In the BeforeUpdate event, place code like this:

If Mid(Me.[Study ID],2,1) <> Me.CaseControlField Then
        msgbox("Study ID does not have the correct case/control value")
        Cancel = True
End If

The field names will need to be what you have on the form.  You can put
whatever in the msgbox you want the user to see.   The Cancel will cause the
record not to be written.

--
Daryl S

laura.dodge said:
Hi, I am trying to figure out a way to verify a piece of data entry.
Study ID is in the form of two letters and three numbers (I'm using
the input mask <LL000;). The first letter will be 'm' for male or 'f'
for female, and the second letter will be 'c' for case and 'x' for
control. There is a separate field for case or control, and boss wants
to make sure that the code matches the case/control field. Can anyone
help me code a macro to check this? Thanks!
.

Thanks for the help! I tried putting the following in the validation
rule: =([ID001]='*c***' And [FB008]=1) Or ([ID001]='*x***' And [FB008]
=2) but it's popping up the validation text every time. Could this
approach work? Thanks again!
 
Back
Top