ACC: Validation Rule to Accept Only Alphabetic CharactersLast reviewed: August 29, 1997Article ID: Q114554 |
The information in this article applies to:
SUMMARYModerate: Requires basic macro, coding, and interoperability skills. This article demonstrates a sample user-defined Visual Basic for Applications function called IsAlpha() that you can use to validate a string to make sure that every character in the string is a letter in the English alphabet. This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual. NOTE: Visual Basic for Applications is called Access Basic in Microsoft Access versions 1.x and 2.0. For more information about Access Basic, please refer to the "Introduction to Programming" manual in Microsoft Access version 1.x or the "Building Applications" manual in Microsoft Access version 2.0
MORE INFORMATIONThe IsAlpha() function accepts a string argument and checks each character in the string to make sure it is a character in the English alphabet. The function does this by checking the ASCII value of each character in the string to see if it falls in the range from 65 to 90 (for uppercase characters), or in the range from 97 to 122 (for lowercase characters), of the ANSI character set. The function returns True if all the characters in the string fall within one of these two ranges, or False if one or more characters in the string do not fall within one of these two ranges. You can use this function as a validation rule for a field in a table in Microsoft Access version 1.x, or as a validation rule for a control on a form in Microsoft Access 1.x, 2.0, 7.0, and 97. The following example shows how to use the function as a validation rule for a control on a form. CAUTION: Following the steps in this example will modify the sample database Northwind.Mdb (NWIND.MDB in 1.x or 2.0). You may want to back up the Northwind.Mdb file, or perform these steps on a copy of the Northwind database.
REFERENCESFor more information about string manipulation, search the Help Index for "strings, manipulating," or ask the Microsoft Access 97 Office Assistant. Keywords : kbprg kbusage PgmHowTo PgmParse Version : 1.0 1.1 2.0 7.0 97 Platform : WINDOWS Hardware : x86 Issue type : kbinfo |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |