Input mask for last name

G

Guest

I would like to create a mask that will force the first letter to be upper
case but optional (upper or lower) for all subsequent letters in the name
like McCarthy. Is this possible?
 
G

G. Vaught

There is some VBA code you can use that will force Proper Case regardless
how someone types in the data. If you use a mask then it would be harder due
to the varing degrees of typed name lengths. You are better off with
sticking with one format either all lower, all upper, or all proper.

Read this article Microsoft Knowledge base.
http://support.microsoft.com/kb/302499/en-us
 
J

John Vinson

I would like to create a mask that will force the first letter to be upper
case but optional (upper or lower) for all subsequent letters in the name
like McCarthy. Is this possible?

Input Masks are simply not flexible enough to do this.

What you can do instead is put some VBA code in the textbox's
AfterUpdate event on a Form (and yes, you must use a form - table
datasheets have no usable events). If the textbox is named txtLastName
the code would be

Private Sub txtLastName_AfterUpdate()
If StrComp(Me!txtLastName, LCase(Me!txtLastName), 0) = 0 Then
Me!txtLastName = strConv(Me!txtLastName, vbProperCase)
End If
End Sub

This will convert any text entered in all lower case to Proper Case
(First Letter Of Each Word Capitalized) but leave anything originally
in mixed case alone.

John W. Vinson[MVP]
 
L

larryo

--
larryo


John Vinson said:
Input Masks are simply not flexible enough to do this.

What you can do instead is put some VBA code in the textbox's
AfterUpdate event on a Form (and yes, you must use a form - table
datasheets have no usable events). If the textbox is named txtLastName
the code would be

Private Sub txtLastName_AfterUpdate()
If StrComp(Me!txtLastName, LCase(Me!txtLastName), 0) = 0 Then
Me!txtLastName = strConv(Me!txtLastName, vbProperCase)
End If
End Sub

This will convert any text entered in all lower case to Proper Case
(First Letter Of Each Word Capitalized) but leave anything originally
in mixed case alone.

John W. Vinson[MVP]
John,
I made about 15 attempts over about 1 1/2 hours, to use the above
information by copying and pasting it into "After Update". However no matter
what changes/modifications I made, it wouldn't work. The Name is LastName,
the Control Source is LastName. When I click on Code Builder and get to the
VBA page, here is what appears:
Private Sub LastName_AfterUpdate()

End Sub
So, I inserted your If statement, in the middle. Should txt be included, or
deleted? I tried it both ways - neither one worked.
Larry O'
 

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