input mask assistance request (1 Viewer)

jfhaccess

New member
Local time
Today, 01:38
Joined
Dec 14, 2009
Messages
1
Apologies in advance. I'm new to access and have been asked to re-work an existing form of a larger application. My background is more with Paradox than access.

Problem: One field is intended to only receive numeric data. The field tho' is defined as text. Because there are a number of reports and possibly other dependencies, I'm reluctant to immediatly do the obvious: convert the 'text' field to a number field. (it has some legacy text entries already)

Going forward I'd like have an input mask on the form that restricts input to numbers, with some sample acceptible field values of:
=========
1
1.1
1.12
12
12.12
...
99999
99999.99
=========
I can see how to fairly easily restrict the input mask to numbers only e.g:
99999

But my efforts so far to allow decimals have failed.

99999;9999.99
or
99999;9999\.99

Any suggestions with more information/examples of input masks would be appreciated.

Thanks,
John
 

missinglinq

AWF VIP
Local time
Today, 04:38
Joined
Jun 20, 2003
Messages
6,423
Input Masks are evil and should be avoided whenever possible! I'd simply prevent the user from entering anything but 0-9 and the decimal, educating them at the same time by popping a message box to remind them to only enter these. Eventually they will become trained to this:
Code:
Private Sub TextBoxName_KeyPress(KeyAscii As Integer)

If (KeyAscii > 47 And KeyAscii < 58) Or (KeyAscii = 8) Or (KeyAscii = 46) Or (KeyAscii = 9) Then
      KeyAscii = KeyAscii
      Else:
      MsgBox ("You Must Enter Digits 0-9 or a Decimal Point Numbers Only!")
      KeyAscii = 0
   End If

End Sub
This only allows the desired characters as well as navigation keys (Left and Right Arrows, <Tab>, <Enter>.)
 

Users who are viewing this thread

Top Bottom