How Does ProperCase work?

G

Guest

I am just learning Access and programing in visual basic and have created a form with code in the "on Exit" event.
I have the following line of code:

StrConv [Supplier Contact], 3

If the first 2 letters are capitalized it will change the text, but it appears that if the text is all caps it will not change it. Also, if the second letter is lowercase and beyond it, there are uppercase letters they will be ignored.

Is this how this function works? I thought it would convert all letters to lowercase and the first letter in every word to uppercase. If this is how it is to work, does anybody have an idea why this is happening?

Thanks
 
R

Rick Brandt

Walt said:
I am just learning Access and programing in visual basic and have created
a form with code in the "on Exit" event.
I have the following line of code:

StrConv [Supplier Contact], 3

If the first 2 letters are capitalized it will change the text, but it
appears that if the text is all caps it will not change it. Also, if the
second letter is lowercase and beyond it, there are uppercase letters they
will be ignored.
Is this how this function works? I thought it would convert all letters
to lowercase and the first letter in every word to uppercase. If this is
how it is to work, does anybody have an idea why this is happening?

Try...

Me![Supplier Contact] = StrConv(Me![Supplier Contact],3)
 
J

Jim/Chris

Thanks Rick. That is alot easier than my suggestion.

Jim
-----Original Message-----
Walt said:
I am just learning Access and programing in visual basic
and have created
a form with code in the "on Exit" event.
I have the following line of code:

StrConv [Supplier Contact], 3

If the first 2 letters are capitalized it will change
the text, but it
appears that if the text is all caps it will not change it. Also, if the
second letter is lowercase and beyond it, there are uppercase letters they
will be ignored.
Is this how this function works? I thought it would
convert all letters
to lowercase and the first letter in every word to uppercase. If this is
how it is to work, does anybody have an idea why this is happening?

Try...

Me![Supplier Contact] = StrConv(Me![Supplier Contact],3)


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


.
 
M

Mike Painter

Walt said:
I am just learning Access and programing in visual basic and have created
a form with code in the "on Exit" event.
I have the following line of code:

StrConv [Supplier Contact], 3

If the first 2 letters are capitalized it will change the text, but it
appears that if the text is all caps it will not change it. Also, if the
second letter is lowercase and beyond it, there are uppercase letters they
will be ignored.
Is this how this function works? I thought it would convert all letters
to lowercase and the first letter in every word to uppercase. If this is
how it is to work, does anybody have an idea why this is happening?I believe that it's function is to just change the first letter to
uppercase.
lCase or uCase will convert to all upper or lower.

If you use this a lot with names be aware that MD gets change to Md and DDS
become Dds.
 
G

Greg Kraushaar

It works fine for me ie as you would expect
Some Tips

StrConv is a function that returns a value. That means that you need
to give it something to put the returned value into. What it does to
the items you pass it is undefined, though good programming means that
they are not changed, except in rare, hopefully well documented cases
where there is a real reason to do so

Always use the inbuilt constants. They make your life easier, not
harder, especially as Access does most of the typing for you.

strConv("frd bloOGG", vbProperCase)

not strConv("frd bloOGG", 3)

In six months time, you will look at the secnond one and wonder what
the hell was I doing there!

The first one is much more obvious

Avoid spaces in names wherever possibe. Sooner or later it will come
back to haunt you. ie
[SupplierContact] not [Supplier Contact]

Finally try
strModifiedValue = StrConv ([SupplierContact], vbProperCase)
[SupplierContact] = strModifiedValue

You can combine the two lines like
[SupplierContact]= StrConv ([SupplierContact], vbProperCase)

but that is less clear at your beginner level, and you should ALWAYS
strive for clarity in your code.
 
G

Guest

where do you enter that code for proper case in a tabl

----- Rick Brandt wrote: ----

Walt said:
I am just learning Access and programing in visual basic and have create
a form with code in the "on Exit" event
I have the following line of code
StrConv [Supplier Contact],
If the first 2 letters are capitalized it will change the text, but i
appears that if the text is all caps it will not change it. Also, if th
second letter is lowercase and beyond it, there are uppercase letters the
will be ignoredto lowercase and the first letter in every word to uppercase. If this i
how it is to work, does anybody have an idea why this is happening

Try..

Me![Supplier Contact] = StrConv(Me![Supplier Contact],3
 
F

fredg

where do you enter that code for proper case in a table

----- Rick Brandt wrote: -----

Walt said:
I am just learning Access and programing in visual basic and have created
a form with code in the "on Exit" event.
I have the following line of code:
StrConv [Supplier Contact], 3
If the first 2 letters are capitalized it will change the text, but it
appears that if the text is all caps it will not change it. Also, if the
second letter is lowercase and beyond it, there are uppercase letters they
will be ignored.to lowercase and the first letter in every word to uppercase. If this is
how it is to work, does anybody have an idea why this is happening?

Try...

Me![Supplier Contact] = StrConv(Me![Supplier Contact],3)
You can't!!!! NOT IN A TABLE!
Tables are used to store data only.
The code Rick Brandt gave you is used in the After Update event of the
[Supplier Contact] control on the form used to enter the data.
Using the StrConv() function will change each word in the field to
First Letter Capital, Each Additional Letter In The Field Lower Case.
This sometimes gives unwanted results.
McDaniel becomes Mcdaniel, O'Hare becomes O'hare, IBM becomes Ibm, and
van den Steen becomes Van Den Steen.
 

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