Limit characters in a numeric field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way (in the table design or in a text box on a form) to limit the
number of characters that can be entered? I know how to do this for a text
field, but I want to do it in a numeric field where users may enter only
digits 1 thru 9.

Any suggestions on the best way to accomplish this?

Thanks.
 
One option-

Modify the Validation Rule Property of the Field &/or Text Box control to
read as:

Between 1 And 9

Also, use the Validation Text Property to enter an error message to display
if the entry doesn't comply with the rule.
 
Gina K said:
Is there a way (in the table design or in a text box on a form) to
limit the number of characters that can be entered? I know how to do
this for a text field, but I want to do it in a numeric field where
users may enter only digits 1 thru 9.

Any suggestions on the best way to accomplish this?

I'm not sure what you mean. Do you mean that the field should only
allow single-digit values from 1 to 9? You could use a validation rule
on the field (set in the table design) to enforce this:

Between 1 And 9

Or you could set such a rule for a text box on a form, but then you'd
have to ensure that data can be entered only by that form.

Or you could use the BeforeUpdate event of the text box to check for a
valid value, and cancel the update if it's not valid. That gives you a
bit more control, but again, you'd have to ensure that data can be
entered only by that form.

If restricting to the values 1-9 is not what you had in mind, but rather
you want to keep people from typing anything but the digits 1-9 into the
text box (so "12345" would be okay, but "12.345" would not), then there
are several ways to accomplish it, including using the control's
KeyPress event to suppress all keystrokes in the control except those
for numeric digits.
 
Back
Top