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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Masks for a field 1

Status
Not open for further replies.

HighLightUK

Technical User
Mar 4, 2003
20
GB
How easy are these to create?

I have a combo box which filters the contents of a subsequent combo box depending on the value selected.

When the user selects a value from the second combo, I would like to create a different input mask for each selection. Then the user only needs to enter a number instead of letters and a number.

If the user selects Fault from combo1, combo2's values will be:

ID Text
1 Emergency
2 Next day response
3 7 day response
4 30D Routine
5 Day Burner
6 Cable Fault

I am trying to force an input mask as follows:

ID Mask
1 E-
2 N-
3 7DF-
4 30D-
5 DB-
6 CF-

If the user selects a 7 day response, the FaultNo field will have a mask of 7DF-, and the user enters a number up to 3 digits in length etc.,
 
To have the combobox2 select records that are determined by the combobox1 selection, create a new query of the table for the second combobox and have the criteria set to the value of the combobox1. You must requery combobox2 in the afterupdate event procedure of combobox1.

As far as creating a spcialized mask based on the combobox2 selection you can do this by modifying the InputMask property in the afterupdate of combobox2. You can include the corresponding mask as part of the query for combobox2. This would just be an additional column by not shown in the dropdown. Give it a width of 0.

Then in the AfterUpdate of that combobox2 put the following code:
me.FaultNo.Inputmask = me.combobox2.column(X)

Now the X is actual column in the query of the mask data minus 1. So, if the mask data is in column 3 then X = 2. This is because the .column property of a combobox starts counting at 0.

Let me know if you need more help with this. Bob Scriver
 
Hi Bob,

Thanks that worked a treat!

A quick overview of what I had to do for anyone else with this sort of problem:

1)Add an additional field to the table with the Job ID and Descriptions for the Mask (I called this FaultMask)
2)Add the required masks in the FaultMask fields of the table formatted exactly as you need(I used the format "7DF-"009;0;_)
3)Update the Row Source of Combo2 to include FaultMask, and as Bob says above, give it a column width of 0
4)Add Bob's code to the AfterUpdate Event of Combo2

Done!
 
Great. Glad to be of help.

I have used this one before where I was populating a column on a subform with a pick of a combobox on the mainform. So, I was using multiple columns from the main form combobox to change Control source and formating properties on the subform column. Then I had an entry box on the mainform that allowed for entry of a search criteria so that I could search the subform column by that data.

Maybe a little confusing but it worked great. Bob Scriver
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top