Formatting a City Name

G

Guest

I have a cell where I enter the name of a city to store it in the DB. I have
a format on it that makes the first letter Caps and all others lowercase.
The problem I have is what if the City name is 2 words. ie.. Los Angeles, New
Orleans. How do I create the format input so that the first letter of the
first word is capitalized and then the first letter of the second word is
automatically capitalized. I can get it to work for the first word but not
the second. Here is what I am using:
L<??????????

Thanks for any help you can provide me in advance.

Nelson Ferry
 
R

Rick B

You don't. What about McAllen? Tell your folks to use that shift ke -
that's why it is there!
 
A

Alex White MCDBA MCSE

There will always be exceptions to the rules, be very careful of input
masks, for flexibility as Rick said teach your users the SHIFT key works
every time once they get in the habit, and input masks/format for what you
are trying will cause you loads of trouble.
 
J

John Mullan

Hi

Look up StrConv function in VB Help - I use vbProperCase as a conversion on
exit from the relevant textbox.
This corrects the names to the style you ask for - but there are always some
that will not fit the pattern.

JohnM
 
J

John Vinson

I have a cell where I enter the name of a city to store it in the DB. I have
a format on it that makes the first letter Caps and all others lowercase.
The problem I have is what if the City name is 2 words. ie.. Los Angeles, New
Orleans. How do I create the format input so that the first letter of the
first word is capitalized and then the first letter of the second word is
automatically capitalized. I can get it to work for the first word but not
the second. Here is what I am using:


Thanks for any help you can provide me in advance.

Nelson Ferry

Just to agree with the others - one initial cap is not always correct.
Here's a little VBA routine I use in the AfterUpdate event of
textboxes containing names (personal names in particular, since I'll
usually have a Cities/Zip table with city names already entered):

Private Sub txtNamefield_AfterUpdate()
' Check to see if user entered all lower case.
' Only change the capitalization if they did so - if they
' manually entered McAllen or Salt Lake City (or san Diego for that
' matter :-{( ) leave it alone.
If StrComp(Me!txtNamefield, LCase(Me!txrFieldname), 0) = 0 Then
Me!txtNamefield = StrConv(Me!txtNamefield, 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