Validating Length From Command Button

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

Guest

Hello

I am trying to validate the length of a field from within a command button with an If statement before they go onto the next record. The only problem I have is that I have 2 different formats to validate
The first consists of 8 digits (e.g. 12345678) the second 2 letters followed by 9 digits (e.g. MB123456789).

If the field does not follow these formats then I wish for a MsgBox to pop up alerting them of the error. (This part is not a problem

If you have or know the relevant coding I would really appreciate it

Thanks in Advance for any help

Hasa
 
You can use the input-mask property. There you can define what format the answer has to have and it will be checked by Access itself. When the answer is not equal to the format, an errormessage is displayed. In you case the first mask would be: 00000000 and in the second case: LL000000000
 
Does this apply when it needs validating in one field as I do

so basically, I am looking at 1 field but need 2 Validations as previously stated
 
Sorry, I misread that.
I don't fully understand your problem. Does the answer have to validate one of the two formats? or do you ask two different questions and use one textfield for it?
 
Sorry if I havent given enough detail....

I have a number fo advisors who enter details of a customer's order into the database, but there is only 1 field for the database and 2 types fo order numbers. I have inherited the database by a former colleague and this was not taken into consideration when the database was designed. As my advisors enter in the details I want to make sure that the data is accurate in terms of length and format.

As previously stated I have 2 types of order number
8 digits e.g. 1234567
2 letters followed by 9 digits e.g. MB12345678

Do to the fact the database has gone to far to redesign I am looking for a way to check the intergirty of the data entered
Therefore as the advisors have entered in the data of one order, before they go onto the next record, I want validation of what they have entered.
 
That's a though one.

What you could try is to create an input mask that covers both, but I don't think it will work.
Just an idea (I don't know if it works!
Before updating adjust in your code the input mask to the first possibility, then try to match the answer to it
When it doesn't match adjust the input mask again and try again
If that doesn't work, give an error-messag

As said before I don't know if it works, but you could try it.
 
Back
Top