Microsoft KB Archive/209520

= ACC2000: How to Ensure That Data Is Saved and Displayed in Uppercase =

Article ID: 209520

Article Last Modified on 7/15/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q209520



Novice: Requires knowledge of the user interface on single-user computers.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SUMMARY
Microsoft Access does not have a simple setting to force entries in a field or control to be saved and displayed in uppercase letters; however, you can use other means to ensure that only uppercase letters are used.

Use a Validation Rule
The following sample validation rule requires that entries in a field or control called Last Name be entered in uppercase letters:

StrComp(UCase([Last Name]),[Last Name],0) = 0

In Microsoft Access 2000, you have two additional alternatives: an input mask, or an event procedure triggered by the KeyPress event.

Use an Input Mask
The following input mask accepts either letters or numbers and makes the first letter uppercase and the following three lowercase:

>C Start Microsoft Access and open the sample database Northwind.mdb. In the Database window, click Forms under Objects, click Suppliers, and then click Design. In the form's Detail section, click the Company Name text box. If the property sheet is not visible, click Properties on the View menu. On the form's property sheet, click the Event tab, and then click On Key Press. Select Event Procedure, and then click the Build Button.  Type the following as the control's On Key Press event procedure: Private Sub CompanyName_KeyPress(KeyAscii As Integer) KeyAscii = Asc(UCase(Chr(KeyAscii))) End Sub </li> Save and close the module; save the Suppliers form, and then open it in Form view.</li> Edit the data in the Company Name text box and notice that all characters are converted to uppercase.</li></ol>

<div class="references_section">