Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field validation

Status
Not open for further replies.

PB90

Technical User
Jul 11, 2005
65
US
I have a field that should look like: 101910ZNOV03

I have created an input mask of: 000000LLLL00

I need to make sure the 7th character is a "Z" and the next three characters are the abreviations for Jan thru Dec.

Is there an easy way to do this?
 
Hi PB90

An easy way is to split your field up, since you are really applying different types of validation to different parts of it.

If you are inputting this value from a form, you can have three unbound fields, one for the first 7 characters, one for the months (Jan-Dec) and one for the last two digits.

The first unbound field can have an input mask of "000000\Z" to force entry of the six digits and to force the seventh character to be "Z".

The second unbound field could be a dropdown supplied with the values of Jan through Dec, or a textbox with the validation rule set only to allow values of Jan through Dec.

The third unbound field could again have an input mask of "00" to force entry of 2 digits.

After Update of this third unbound field you could set the value of the bound field that is designed to hold the whole value (e.g. "123456ZJAN01").

Code:
Me.MyBoundField=Me.MyUnboundField1 & Me.MyUnboundField2 & Me.MyUnboundField3

This line of code concatenates the values of your three unbound fields into one single value in the format you desire.

Hope this helps.

Mac
 
Thank you Mac,

It hadn't occurred to me to split the fields. I believe I will do that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top