How do I set it up to automatically capitalize the 1st letter?

S

Sol

I am learning to use Access 2003. I want the database to automatically
capitalize the 1st letter of the last and first name.
 
F

fredg

I am learning to use Access 2003. I want the database to automatically
capitalize the 1st letter of the last and first name.

Using a form for the data entry, code the AfterUpdate event of the
FirstName control to:

Me![FirstName] = StrConv([FirstName],3)

Do similar code in the LastName AfterUpdate event as well.

Note: this will improperly capitalize any name that normally should
have more than one capital, i.e. O'Brien, McDonald, Smith-Young, etc.
and also incorrectly capitalize names that should not be capitalized,
i.e. van den Steen, etc.
 
J

John W. Vinson

I am learning to use Access 2003. I want the database to automatically
capitalize the 1st letter of the last and first name.

Here's some VBA code I use in the AfterUpdate of each textbox for which you
want this to happen. It checks first to see if the user has already input
mixed case, so as not to mess up correctly capitalized names such as
"O'Brien", "McDonald" and "van der Steen".

Private Sub textboxname_AfterUpdate()
If StrComp(Me!textboxname, LCase(Me!textboxname), 0) = 0 Then
Me!textboxname = StrConv(Me!textboxname, vbProperCase)
End If
End Sub


John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top