Input Mask in Access textbox. Allow only digits, no spaces.

Fritz Paul
Fritz Paul used Ask the Experts™
on
I have a textbox on a form where I only want to allow either four or five digits with no spaces.
Mask     00009     requires at least that the first four entries are digits and the fifth one can either be a digit OR A SPACE.
How can I prevent users from adding a space at the end of the four digits? There must either be a digit or nothing.
Unfortunately the field format is text and can for reference reasons not be changed.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
Hi,

You could use the Trim function to eliminate the space

Regards
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
> a digit or nothing.

But that is "9". When saved, Access strips trailing spaces.
If used for a variable, apply (as already noted) Trim or even RTrim.

/gustav

Author

Commented:
Thanks. I did not even try, because I read http://office.microsoft.com/en-za/access-help/input-mask-syntax-and-examples-HP005187550.aspx
It says there
9      Digit or space (entry not required; plus and minus signs not allowed).
So I did not want to allow a space.
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
You are welcome!

/gustav

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial