input masks

arm1

Registered User.
Local time
Today, 16:33
Joined
Nov 21, 2006
Messages
40
For an unbound field with a query as its drop-down list...

If you create an input mask... say of format 00000... then as you start typing in the values, the system removes the zeros.

Ex:

When I enter the field, it shows 00000

If I type in a 1, it shows 10000
Then if I type a 3, it shows 13000

IS THERE A WAY TO REVERSE THIS ???????????????????????????

Ex:

When I type 1, it shows 00001

Then if I type in a 3, it shows 00013

etc...

Thanks for any help, anyone can provide

- arm1
 
Well, u could try the following: add a button "btnReverse" to your form and put the following code behind it:

Private Sub btnReverse_Click()
Dim invertedNumber As String
Dim bytCounter As Byte
Dim leftDigits As String
Dim allDigits As String
leftDigits = ""
bytCounter = 1
Do
leftDigits = LeftDigs(bytCounter)
If Right(leftDigits, 1) = "0" Then Exit Do
allDigits = leftDigits
bytCounter = bytCounter + 1
Loop While bytCounter < 6
bytCounter = bytCounter - 1
Select Case bytCounter
Case 1
invertedNumber = "0000" & allDigits
Case 2
invertedNumber = "000" & allDigits
Case 3
invertedNumber = "00" & allDigits
Case 4
invertedNumber = "0" & allDigits
Case 5
invertedNumber = allDigits
End Select
Me.txtNumber = invertedNumber
End Sub

Now copy this function to the form:

Private Function LeftDigs(bytCnt As Byte) As String
Dim inputNumber As String
Dim dig As String
inputNumber = CStr(Me.txtNumber)
dig = Left(inputNumber, bytCnt)
LeftDigs = dig
End Function

Replace "txtNumber" with the name of your actual control.

All this here will work for a 5 digit number. For more or less digits, adapt the code accordingly.

U may of course choose to run this code thru another event.

HTH
 
remove the input mask from the text box but set the Format to Fixed no decimal places then on the after update of the field state

Me.ActiveControl = Format(Me.ActiveControl,"00000")

David
 
Nothing beats experience! Thanks for the lesson DCrake!
 

Users who are viewing this thread

Back
Top Bottom