Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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<CCC

Use the On Key Press Event Procedure

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

To change letters to uppercase as you type them in a control, follow these steps:
  1. Start Microsoft Access and open the sample database Northwind.mdb.
  2. In the Database window, click Forms under Objects, click Suppliers, and then click Design.
  3. In the form's Detail section, click the Company Name text box.
  4. If the property sheet is not visible, click Properties on the View menu.
  5. On the form's property sheet, click the Event tab, and then click On Key Press.
  6. Select Event Procedure, and then click the Build Button.
  7. 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
    					
  8. Save and close the module; save the Suppliers form, and then open it in Form view.
  9. Edit the data in the Company Name text box and notice that all characters are converted to uppercase.

↑ Back to the top


References

For more information about input masks, click Microsoft Access Help on the Help menu, type inputmask property in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

For more information about validation rules, click Microsoft Access Help on the Help menu, type validationrule, validationtext properties in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

For more information about the On Key Press 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.

↑ Back to the top


Keywords: KB209520, kbhowto

↑ Back to the top

Article Info
Article ID : 209520
Revision : 3
Created on : 7/15/2004
Published on : 7/15/2004
Exists online : False
Views : 284