Title Case

L

LMB

Hello,

I would like to set my database up so when the typist uses either upper or
lower case when typing in a name it changes it to First letter Cap and the
rest lower case. I found that if in the table I use this > symbol, all the
letters are capitol...If I put it in the format field in the table, will it
work in all objects of the database?

Is this the best place to set this? Also, what is it called? A rule,
expression?????

Thanks,
Linda
 
F

fredg

Hello,

I would like to set my database up so when the typist uses either upper or
lower case when typing in a name it changes it to First letter Cap and the
rest lower case. I found that if in the table I use this > symbol, all the
letters are capitol...If I put it in the format field in the table, will it
work in all objects of the database?

Is this the best place to set this? Also, what is it called? A rule,
expression?????

Thanks,
Linda

Code the Form Control's AfterUpdate event:
[ControlName] = strConv([ControlName],3)

This will change JOHN SMITH to John Smith.
Unfortunately it will also change names like O'Brien, MacGregor, van
den Steen and IBM to O'brien, Macgregor, Van Den Steen, and Ibm.
 
J

John Vinson

Hello,

I would like to set my database up so when the typist uses either upper or
lower case when typing in a name it changes it to First letter Cap and the
rest lower case. I found that if in the table I use this > symbol, all the
letters are capitol...If I put it in the format field in the table, will it
work in all objects of the database?

Is this the best place to set this? Also, what is it called? A rule,
expression?????

I hate to disagree with my friends Fred and Rob but they're talking
about Proper Case, That Is, Every Word Capitalized - not title case as
you request.

If you want properly capitalized English sentences, with words like I
and proper names capitalized, there is no function (that I know of) to
do so. If you want to capitalize just the first letter of the text
entered to be capitalized, you could use the AfterUpdate event of the
textbox:

Private Sub txtTextfield_AfterUpdate()
Me!txtTextfield = UCase(Left(Me!txtTextfield, 1)) _
& Mid(Me!txtTextfield, 2)
End Sub
 
L

LMB

Thanks,
This is just for the FName and LName fields. I don't know exactly how to or
where to use an After Update event. Is that in the form? Will that change
the case in the table it's linked to so on all queries and reports it will
look and pring right?

Could you explain where to put this?

Thanks,
Linda
 
J

John Vinson

Thanks,
This is just for the FName and LName fields. I don't know exactly how to or
where to use an After Update event. Is that in the form? Will that change
the case in the table it's linked to so on all queries and reports it will
look and pring right?

Could you explain where to put this?

Sure. You need to do it on the Form; this code will permanently store
the corrected capitalization in the table, so the text will appear
correctly anywhere it's used. (A Format property will NOT do this).

Open the Form in design view; select the FName control and view its
properties. On the Events tab find the AfterUpdate event. Click the
.... icon by it and select "Code Builder". Access will give you the Sub
and End Sub lines; edit it to read

Private Sub FName_AfterUpdate()
' Only change text if it's all lower case; this lets the user
' put in MacDonald or van der Steen without the code messing
' it up to Macdonald and Van Der Steen
If StrComp(Me!Fname, LCase(Me!Fname), 0) = 0 Then
Me!FName = StrConv(Me!FName, vbProperCase)
End If
End Sub

Do the same (changing the name of the control of course) for each
other textbox for which you want this done: if you're entering cities
or addresses, you might want to do it there as well.
 
L

LMB

Here is what mine ended up being...

Private Sub strPtLastName_AfterUpdate()
' Only change text if it's all lower case; this lets the user
' put in MacDonald or van der Steen without the code messing
' it up to Macdonald and Van Der Steen
If StrComp(Me!strPtLastName, LCase(Me!strPtLastName), 0) = 0 Then
Me!FName = StrConv(Me!strPtLastName, vbProperCase)
End If


End Sub

All the letters in the strPtLastName field are in caps. Did I miss
something or set it up wrong to start with? There are already 120 records
in there and they were all converted to Upper Case.

The record source is qryInformation which the source for that is the
tblInformation. When I look at both of those objects the names are not in
capitols they are in the case I typed them in.

Thanks,
Linda
 
J

John Vinson

Here is what mine ended up being...

Private Sub strPtLastName_AfterUpdate()
' Only change text if it's all lower case; this lets the user
' put in MacDonald or van der Steen without the code messing
' it up to Macdonald and Van Der Steen
If StrComp(Me!strPtLastName, LCase(Me!strPtLastName), 0) = 0 Then
Me!FName = StrConv(Me!strPtLastName, vbProperCase)
End If


End Sub

All the letters in the strPtLastName field are in caps. Did I miss
something or set it up wrong to start with? There are already 120 records
in there and they were all converted to Upper Case.

The record source is qryInformation which the source for that is the
tblInformation. When I look at both of those objects the names are not in
capitols they are in the case I typed them in.

My code assumes that if the data in the field is in all lower case as
typed, that it should be converted to proper case; if it contains ANY
capitol letters the If Strcomp... expression will be False and the
program will leave the information alone. If you want to convert
either "jim smith" or "JIM SMITH" to "Jim Smith", but leave "Jim
MacCarty" alone, change the line to

If StrComp(Me!strPtLastName, LCase(Me!strPtLastName), 0) = 0 _
OR Me!strPtLastName, UCase(Me!strPtLastName), 0) = 0 Then

Also, check the Format property of the textbox in which you are
displaying strPtLastName, and the Format properties of the field in
the table and in the query. If any of them have > in the Format, then
it will *display* all caps, regardless of the case of the text in the
field. Just remove the > format.
 
L

LMB

John Vinson said:
My code assumes that if the data in the field is in all lower case as
typed, that it should be converted to proper case; if it contains ANY
capitol letters the If Strcomp... expression will be False and the
program will leave the information alone. If you want to convert
either "jim smith" or "JIM SMITH" to "Jim Smith", but leave "Jim
MacCarty" alone, change the line to

If StrComp(Me!strPtLastName, LCase(Me!strPtLastName), 0) = 0 _
OR Me!strPtLastName, UCase(Me!strPtLastName), 0) = 0 Then

Also, check the Format property of the textbox in which you are
displaying strPtLastName, and the Format properties of the field in
the table and in the query. If any of them have > in the Format, then
it will *display* all caps, regardless of the case of the text in the
field. Just remove the > format.

Ok...now I think I know how to post my question/need. I want the code to
convert the text however it is entered by the user into first letter upper
case and the rest lower case. If there are 2 words to the name.. Mary Jane
I want each word in the same format.

If they typed linda----I want Linda, if they type LINDA I want Linda, if
they type lINDA, I want it to be Linda on the table, the queries, the form
and the reports.

Sorry I keep forgetting to bottom post. Is there anyway to get my OE 6.0 to
drop the curser to the bottom of the thread instead of the top?

Thanks,
Linda
 
J

John Vinson

Ok...now I think I know how to post my question/need. I want the code to
convert the text however it is entered by the user into first letter upper
case and the rest lower case. If there are 2 words to the name.. Mary Jane
I want each word in the same format.

If they typed linda----I want Linda, if they type LINDA I want Linda, if
they type lINDA, I want it to be Linda on the table, the queries, the form
and the reports.

Ok... in the AfterUpdate event, just remove the If and the End If:

Private Sub txtFName_AfterUpdate()
Me!txtFName = StrConv(Me!txtFName, vbProperCase)
End Sub

Note that this will prevent the user from *correctly* entering names
like van Huyck or MacKeith; they'll come out Van Huyck and Mackeith
respectively.
 
N

Newbie

Try putting the field name in brackets i.e. [Plan Name]

If you have spaces in your field names you should always place them in
brackets.

HTH
beejsnyder said:
John:

I'm trying to use your information here. I want to make my text fields
automatically capitalize the first letter only. When I entered your code
into the code builder and attempted an update (to 'check it out') it
returned an error message that it couldn't find the field I had indicated.
Well, the name of the field is "Plan Name" and the Code Builder had
automatically called it "Plan_Name", so I'd duplicated that name within the
code.
So I returned to the code to remove the underscore, but that seemed to
cause it's own problem as the code/text in the code builder turned red.
(possibly I made it angry?)
So how can I use your genius here? Any help is appreciated.

And a side question: I'd like to be more savvy w/ Access, especially with
expressions and such. Where did you acquire your knowledge about making
Access do all it should do? VB class? Access class or book? Thanks!
 

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