Input Mask

T

Troy W

I have a textbox for a name. I would like to put an input mask to force a
capital letter for the first letter in the name, but I have a problem with
names where there is another capital in it. If I do >L<LL it forces the
last two letters to be lowercase, even if I want it to be capital. Any help
would be really appreciated.

Troy W.
 
D

DL

Are you using names such as;
1) McAfee
2) Lawson Martin
3) Lawson-Martin
If using only (2) not to much problem, but a combination - difficult.
 
J

John Vinson

I have a textbox for a name. I would like to put an input mask to force a
capital letter for the first letter in the name, but I have a problem with
names where there is another capital in it. If I do >L<LL it forces the
last two letters to be lowercase, even if I want it to be capital. Any help
would be really appreciated.

Troy W.

Input masks simply are not capable of handling the complexity of name
capitalization.

What I do instead is use a bit of VBA code in the AfterUpdate event of
the name textbox, to see if the name is all lower case; if so it uses
the builtin StrConv() function to convert it to Proper Case (Each Word
Capitalized). If it's already mixed case, I'll assume that the user
wants it that way (McArthur or de la Cruz or Jones-Smith for example):

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

John W. Vinson[MVP]
 
D

DL

As an afterthought, and in addition to John's post, as user exits the field,
a msg box that shows the text and requires a yes/no response.
 

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