I have a text box where I want to allow the user to enter at most 5 digits
to the left of the decimal and 3 to the right. I'd normally mask this as
follows:
99999.999
I also need to allow them to enter negatives but I DON'T want to allow for 6
digits to the left of the decimal. I still want 5. But it appears that I'm
stuck with this so that they can enter the minus sign and still have 5
digits. The trouble is that this also now would allow 6 digits for positive
values.
#99999.999
Is there a way to mask this so that I get the behavior my client requires?
Thanks,
Keith
KARL DEWEY - 01 Oct 2007 17:40 GMT
Have you thought about using a number field instead of a text field?

Signature
KARL DEWEY
Build a little - Test a little
> I have a text box where I want to allow the user to enter at most 5 digits
> to the left of the decimal and 3 to the right. I'd normally mask this as
[quoted text clipped - 15 lines]
>
> Keith
Keith G Hicks - 01 Oct 2007 17:47 GMT
A2k by the way.
Thanks but it is a numeric field. That's got nothing to do with it. If a
text box is bound to a numeric field, the user can still type in any ole
thing he wants. An error doesn't occur until he attempts to post it. I need
to mask it so he cannot enter an invalid value in the first place. In a
language like Delphi I can mask a text box so that the +/- has nothing to do
with the digits being typed. I'd do something like this: [+/-]99999.99. The
user can ONLY type 5 numeric values to the left of the decimal and can
precede them by either a "+" or "-" at his option. They're separate issues.
I need to know if this can be done in Access.
Keith
> Have you thought about using a number field instead of a text field?
> --
[quoted text clipped - 20 lines]
> >
> > Keith
KARL DEWEY - 01 Oct 2007 19:43 GMT
In your form text box use this as the input mask ---
#####.###

Signature
KARL DEWEY
Build a little - Test a little
> A2k by the way.
>
[quoted text clipped - 39 lines]
> > >
> > > Keith
Keith G Hicks - 01 Oct 2007 21:30 GMT
That doesn't solve the problem. Try it. It still only allows you to type in
4 digits if you use a minus sign. And it has the added flaw of letting a
user type in things like "----.98" which generates an error on post.
I'm guessing there's no good masking solution to this and I'll have to write
BeforeUpdate code to handle it or I just am stuck with using 6 mask
characters which could allow 6 digits to the left or a combination of both.
Ugh. I wish Access had more complex masking capabilities (like "regular
expressions" masking).
> In your form text box use this as the input mask ---
> #####.###
>
> --
> KARL DEWEY
> Build a little - Test a little
Pieter Wijnen - 02 Oct 2007 02:06 GMT
Private Sub Text0_BeforeUpdate(Cancel As Integer)
Dim NotNeg As Double
If IsNull(Me.Text0.Value) Then Exit Sub
NotNeg = Abs(Me.Text0.Value)
If NotNeg > 99999 Then
Cancel=True
ElseIf NotNeg - Clng(NotNeg) < 0.001 Then
Cancel=True
End If
If Cancel Then
Beep
'MsgBox "Naughty, Naughty"
End If
End Sub
HtH
Pieter
>I have a text box where I want to allow the user to enter at most 5 digits
> to the left of the decimal and 3 to the right. I'd normally mask this as
[quoted text clipped - 17 lines]
>
> Keith