UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

> Interesting Input Mask Issue    
 
   
michaela4
post Sep 12 2005, 02:32 PM
Post #1

UtterAccess Ruler
Posts: 1,395
From: Tulsa, Oklahoma



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!

Michael
Go to the top of the page
 
+
 
Start new topic
Replies (1 - 10)
bome
post Sep 12 2005, 02:44 PM
Post #2

UtterAccess VIP
Posts: 1,644
From: Sweden



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.
________
Bo Melin

Edited by: bome on Mon Sep 12 15:47:29 EDT 2005.
Go to the top of the page
 
+
YK102
post Sep 12 2005, 02:48 PM
Post #3

UtterAccess Enthusiast
Posts: 73
From: Canada



seems like:
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?
Go to the top of the page
 
+
Jack Cowley
post Sep 12 2005, 02:50 PM
Post #4

Retired Moderator
Posts: 37,716
From: The San Francisco Bay Area



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)
Case 3
Me.ControlName = Left(Me.ConrolName,1) & "-" & Mid(Me.ControlName,2,1) & "-" & Right(Me.ControlName,1)
Case 4
...
End Select

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...

hth,
Jack

Edited by: Jack Cowley on Mon Sep 12 15:52:50 EDT 2005.
Go to the top of the page
 
+
michaela4
post Sep 12 2005, 04:06 PM
Post #5

UtterAccess Ruler
Posts: 1,395
From: Tulsa, Oklahoma



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!

Michael
Go to the top of the page
 
+
YK102
post Sep 12 2005, 04:11 PM
Post #6

UtterAccess Enthusiast
Posts: 73
From: Canada



seems over complicated, and doesn't solve the problem for the 3 digit code.
Go to the top of the page
 
+
Jack Cowley
post Sep 12 2005, 04:18 PM
Post #7

Retired Moderator
Posts: 37,716
From: The San Francisco Bay Area



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.

hth,
Jack
Go to the top of the page
 
+
michaela4
post Sep 12 2005, 04:18 PM
Post #8

UtterAccess Ruler
Posts: 1,395
From: Tulsa, Oklahoma



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

thanks
Michael
Go to the top of the page
 
+
spy
post Sep 12 2005, 05:07 PM
Post #9

UtterAccess Veteran
Posts: 457
From: Porto Alegre - Brazil



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...
Go to the top of the page
 
+
YK102
post Sep 12 2005, 05:51 PM
Post #10

UtterAccess Enthusiast
Posts: 73
From: Canada



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.
Go to the top of the page
 
+
spy
post Sep 13 2005, 07:22 PM
Post #11

UtterAccess Veteran
Posts: 457
From: Porto Alegre - Brazil



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.,
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th May 2013 - 04:18 AM