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.
Consider the form below:
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.
Open the form in design view. Click on the View Code button:
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:
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:
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))
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:
Add the following code for the
Private Sub Last_Name_LostFocus()
Last_Name.Text = UCase(Left(Last_Name.Text, 1)) _
& LCase(Right(Last_Name.Text, Len(Last_Name) - 1))
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:
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