Capitalize first letter

C

cmichaud

If i want to make sure that the first letter is capitalized do i use in
input mask of

A*

I am trying to make sure that when a user enters a value into a field
that it is committed to the database with the first letter of every
word being capitalized. for instance the city of New York, i would want
it to show New York, not new york.....even if the user entered new
york.
 
R

Rick B

Your example is the perfect reason why you can't/shouldn't do this. In your
example, you'd get "New york" not "New York".

There are complex routines you could use to capitalize the first letter of
each word. There is also a "proper case" that will do it, but you have too
many exceptions. What about...
Maria de los Santos
John McDonald
Fond du Lac

I can't think of any cities off hand, (except Fon du Lac, Wisconsin) but I
know there are very similar exceptions.

It is generally recommended that you don't try to correct people's
capitalization. If they can't use the shift key, then maybe they are in the
wrong job :p

If you still want to do it, I Think the best way is to run code after the
field is updated to convert the entry to proper case. Do a search on
previous posts for the keyword "proper case" and you will most likely find
some examples of the code.
 
A

Al Camp

Since you'll never know what length the lower case city name/s will be, I would think a
"one size fits all" Input Mask can not be developed.

A simple solution is to use the AfterUpdate event of city...
Me.City = StrConv(City,3)

This will capitalize the first letter of each "word" in the city name.
I only suggest this because "most" (perhaps 99%?) of City names contain 1 or 2 words,
or... at least most "words" in a city name are seperated by spaces.

This would not work for "people's" names such as...
MacDonald = Macdonald
VanDyke = Vandyke
Or, very rarely... city names like...
Santa del la Cruz = Santa De La Cruz
 
C

cmichaud

Rick.

Thanks for the insight. I guess i will just leave as is. And kick the
user in the butt if they fail to hit the shift key.
 
C

cmichaud

Al

I tried your suggestion and it didnt work. I wonder if it is because i
also have a 'not in list' event set for city.....or because my field is
linked to a tblCity (cityID, city).....and is hiding column one
displaying column two. Either way when i tested it....it didnt work.
Any ideas why?
 
A

Al Camp

I am trying to make sure that when a user enters a value into a "field"...

You didn't say anything about a combobox.
Your combo is storing the CityID in that field, not the CityName, so you can't change
the CityName there.
You should be controlling the CityName entry in your tblCity entry form, using the
method I suggested... not when you refer to it later in a combobox. There's nothing you
can do about that at that time. Make sure all your CityNames are entered correctly into
tblCity.

And... why are you using an input mask on a combo? "new York" or "NEW York" or "NeW
yorK" would all find your New York entry, then "display" the actual CityName stored value
in the combo field.

Better to prevent a problem in the first place, than code later to fix it...
 
C

cmichaud

Al

Here is the problem. In my CityID combobox on the form i am using a
'not in list' event to update tblCity. It is impossible for me to list
every city in the area. Just not reasonable so i am allowing the user
to enter a city. Maybe that is trusting them too much? Right now i
dont have an input mask. I was trying to figure out how, if the city
is not in the drop down, the user can use the not in field event, and
when the city is added it will have its first letter capitalized.
 
A

Al Camp

OK...
On my website (below) I have a sample A97 and A2003 NotInList downloadable file that
shows how to add "Not in List" item to the combos supporting table.
I use State, but City would be exactly the same method...
All you would have to do is add the StrConv function to the NotInlist code to
capitalize the City before it's saved to the City table.
 

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