How to Restrict the Character Entry

The medication helped in enhancing the buying cialis in spain erection thus making it hard to erect. In addition, a person may buy viagra usa face difficulty in conceiving a child. The same testosterone-based products, which come either as patches or pills, are also advisable for viagra online store women who have had children. Most of the side effects are very minor and subside after a few hours of taking the drug. generic viagra sample


There are many types of data to be entered into the field or text box on form. Some fields only required a certain data type of entry such as a Customer field name needs only an alphabet (letter) character, telephone field requires only a number, or zip code requires a number etc. We can restrict the character entry for these fields at the time of data entry. That means it will not accept another character than it is specified in the VBA code. For this How To, I will use a Customer Form to make an entry restriction on field Last Name and Zip Code.

customer form

Accepting only Letter Entry

Step #1 Open a form in a Design View mode.

Step #2 Click on Customer_Last_Name field

Step #3 Then select a [Event Procedure] for On Key Press under Property Sheet

Step #4 Click on three dots (…) after [Event Procedure]

alpha entry

Step #5 Enter VBA code below, use a Select Statement to allow only certain KeyASCII to be entered. The number 65 -90 (A-Z) and 97 – 122 (a –z) represents the letters. Note: you may need KeyAscii 2D (-) if you want.

alpha code

Example of other character is entered.

The Last Name field is restricted to accept only the letters. You will get an alert message if you enter a number into this Last Name field as shown in the picture below.

alpha message

Accepting only Number Entry

Follow the same steps above on the Zip code field and edit the VBA code to allow only a number to be entered into this field by using the KeyAscii 48 – 57 (0-9)

customer design view

vba key press
Example of other character is entered.

The Zip Code field is restricted to accept only numbers. The alert message will pop-up if you enter a letter into this Zip Code field as shown in the picture below.

wrong entry

Table of Ascii characters here: http://www.asciitable.com/




Related posts