Article ID: 210047 - View products that this article applies to.
This article was previously published under Q210047
Moderate: Requires basic macro, coding, and interoperability skills.
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).
This article shows you two techniques that you can use to limit the number of characters that can be typed in an unbound text box on a form.
You can limit the number of characters that can be typed in an unbound text box control in one of the following ways.
Method 1You can specify an InputMask property setting. This is by far the simplest method. For example, a text box with the following InputMask property setting limits the number of characters typed in a text box to five:
Input Mask: CCCCC
Method 2You can use a Visual Basic for Applications function called from the KeyPress event. Although an InputMask is easy to implement, it may be tedious and error prone to use if you need to limit the number of characters to a much larger value, such as 50 characters.
To limit the number of characters typed in a text box to 50, follow these steps:
For more information about KeyPress event, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type KeyPress Event in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
Contact us for more help
Connect with Answer Desk for expert help.