Sep 12 2005, 02:32 PM
I have a textbox that holds data in the following format:
12-15-33 or 1-5-9 or 1-25-33
each number can be a one digit or two digit number. I would like to create an input mask that will allow the user to input without having to type the dashes. The problem being that sometimes we have a one digit number and sometimes a two digit number. there cannot be any zeros used in the number. i.e. 01. Is there a way to write code on the after update or before update of the textbox the will read 122233 as 12-22-33 or 12233 as 1-22-33 and so on?
Thanks for any help!
Sep 12 2005, 02:44 PM
As far as I can see it's impossible to do it with an input mask. If you enter 12233 should it be interpreted as
1-22-33 or 12-2-33 or 12-23-3 ?
If you can define an unambiguous rule how the entered numbers should be interpreted you can use the control's AfterUpdate event to adjust what the user has entered.
Edited by: bome on Mon Sep 12 15:47:29 EDT 2005.
Sep 12 2005, 02:48 PM
if length is equal to 3 then it should be #-#-#
if length is equal to 5 then it should be #-##-##
if length is equal to 6 then it should be ##-##-##
do I understand it right?
Sep 12 2005, 02:50 PM
I know of no way to use an input mask and I personally don't like them anyway. I would write code to insert the hypens, depending on the length of the input string, and then run the code in the After Update event of the control where the user enters the numbers... As an example -
Select Case Len(Me.ControlName)
Me.ControlName = Left(Me.ConrolName,1) & "-" & Mid(Me.ControlName,2,1) & "-" & Right(Me.ControlName,1)
The above is air code and has NOT been tested, but should give you an idea... Also, 'bome' has a good point about possible variations on 2-33-44 so unless there is a hard and fast rule there is no way to do what you want...
Edited by: Jack Cowley on Mon Sep 12 15:52:50 EDT 2005.
Sep 12 2005, 04:06 PM
My original thought was that I would need the afterupdate or the beforeupdate properties of the textbox to do this. The hard and fast rule is there is a minimum of 3 digits and a maximum of 6. I can see what you mean by the problem I face. I'm left with creating 3 textboxes with 2 as the length number only format. Then concatenating the 3 textboxes in a 4th bound field dropping any leading zeros. I believe I can also force a cursor advance to the next textbox after the 2nd digit is typed? Any thoughts on this method???
thanks again guys!
Sep 12 2005, 04:11 PM
seems over complicated, and doesn't solve the problem for the 3 digit code.
Sep 12 2005, 04:18 PM
I would not bother with code to move to the next text box because it may not always be triggered if the user only enters a single digit and I do not see forcing them to enter two digits if only one may be required. Most people are used to using the Enter or Tab key to advance to the next text box on a form. Also, I am not sure of the purpose of this number so having 3 fields in the table may work instead of concatenating the data and then use your idea to display the data in 3 adjoining text boxes with a hypen between the text boxes. You can use 3 unbound text boxes if you want the data concatenated...
There are a number of ways to skin this cat and I think you will have to choose the one that will work best for your users and the purpose of this aspect of the database.
Sep 12 2005, 04:18 PM
no 3 digit problem. the format has a minimum of 1 digit and maximum of 2 per dash i.e. 1-22-33 or 1-2-5 or 12-11-33. I need to create a solution for the users to not have to enter the dashes everytime. complicated or not they don't want to do that. lol
Sep 12 2005, 05:07 PM
Hi, having to type the dashes is not a comfortable thing to do, indeed. Maybe using dots it could be achieved just with the number pad...
Sep 12 2005, 05:51 PM
I'm saying that the multiple text box option is complicated when you can have them enter the number without dashes and use code to enter the dashes.
Sep 13 2005, 07:22 PM
Well, we will have to first define a rule that says if a typed value like "1111" is supposed to be "1-1-11" or 1-11-1" or "11-1-1". If there are no valid sequences for each part, there are some approaches to offer to the user:
Your suggestion of three textboxes with two-digits each: user have to type, say, 010111. But would these zeros be natural for the user? Wouldn't it promote typing errors by changing te "business rule? And we just changed the dashes for zeros in this case. Not a great benefit!
Allow the user to enter "1111". Now, thru code, create all possibilitys and present them to the user - "Please, select the correct one" (Ok, it's a joke)
I know, sometimes there is no argumentation that convices the user, but, if these dashes are someting from his/her business, he/she will have to live with it - just two (extra?) key presses.,
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here