Validating data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I need to validate data that is entered by the user on a form in Access.
For data such as:

Specifically, I have a 7 character field where the first two characters must
be a letter and characters 3-7 must be a number. I don't know the VBA
syntax, but I think I need to use a string function to get the first two
characters then verify they are letters. Then of course, use a string
function to get the last 5 characters and verify that they are numbers. If
either check fails, I need to display an appropriate error message.

Can anyone help me with the proper syntax?
How can I check if a string is character or numeric?

Thanks in advance,
Rich
 
In table design view, select the field, and in the lower pane set its
Validation Rule property to something like this:
Is Null Or Like "[a-z][a-z][0-9][0-9][0-9][0-9][0-9]"

More info and examples of validation rules:
http://allenbrowne.com/ValidationRule.html

Depending on what this is for, you might be better of using 2 fields. If the
first 2 characters represent something, and the number represents something
else, it is better to make the fields atomic (i.e. use 2 fields to store the
2 different things.)
 
Back
Top