First Letter Uppercase Only Access Form
This article explains how you can format the user input in an Access form so that the first character will appear as uppercase and the rest of the input will appear as lowercase, regardless of the way the user has input the data. The method explained in this article uses VBA.
The user can input a first and last name in the form. We want to the first letter of the input to appear as upppercase and the rest of the input to appear as lowercase regardless of how the user decides to input values in the textboxes.
Contents
Step 1:
Open the form in design view. Click on the View Code button:
Step 2:
Select the form class from the Project Explorer on the left. Select the textbox from the drop down list. In this example it’s First_Name:
Step 3:
Select the LostFocus event from the drop down list on the right. Basically we want this conversion to occur “after” the user has finished inputting text:
The code below will be generated:
Step 4:
Add the following code to the LostFocus event handler:
Private Sub First_Name_LostFocus()
First_Name.Text = UCase(Left(First_Name.Text, 1)) _
& LCase(Right(First_Name.Text, Len(First_Name.Text) - 1))
End Sub
Note: It is assumed that the name of the textbox is
. The name of the textbox can be modified in design view from the Property Sheet: First_Name
Step 5:
Add the following code for the
textbox:Last_Name
Private Sub Last_Name_LostFocus()
Last_Name.Text = UCase(Left(Last_Name.Text, 1)) _
& LCase(Right(Last_Name.Text, Len(Last_Name) - 1))
End Sub
Result:
No matter how the user inputs values in the First_Name and Last_Name textboxes, the first character will be converted to uppercase and the rest will be converted to lowercase.
You can download the sample file used in this article from the link below:
See also:
- Access, Add Leading Zeros Custom Number Formats
- Access, Convert User Input to Uppercase
- Access, Convert User Input to Lowercase
- Access Field Properties Locked
- Access Check If Field is Null, Conditional Macro
- First Letter Uppercase Only Access Tables
- Access, Fixed Decimal Places Number Format
If you need assistance with your code, or you are looking for a VBA programmer to hire feel free to contact me. Also please visit my website www.software-solutions-online.com
3 thoughts on “First Letter Uppercase Only Access Form”