First letter to upper case

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

I would like to automatically change the first letter to upper case and keep
the rest intact of each word on a control of a form. Is there any functions
to do this job?

Thanks,

Scott
 
Scott,
Using an Update query to change a field called [SomeText]...
Update To : UCase(Left(SomeText,1) & Mid(SomeText,2)
should do it.
 
Dear Scott, Al:

Al has provided a process to convert the first letter of the string to upper
case and leave the rest of the string unchanged, as in:

the big man > The big man

Scott, you *may* be asking to convert like this (the working of your
question is a bit confusing):

the big man > The Big Man

If so, and if you are talking about a textbox on a form called, say,
"txtSomeWords", then you can use the AfterUpdate event of the control to
make this change, like so:

Private Sub txtSomeWords_AfterUpdate()
Me.txtSomeWords = StrConv(Me.txtSomeWords, vbProperCase)
End Sub

If you want to use this process in a query, IIRC, you must use "3" instead
of vbProperCase...

HTH
Fred Boer

P.S. Al, I think there was a typo in your example... I think you meant to
write: UCase(Left(SomeText,1)) & Mid(SomeText,2)

Al Campagna said:
Scott,
Using an Update query to change a field called [SomeText]...
Update To : UCase(Left(SomeText,1) & Mid(SomeText,2)
should do it.
--
hth
Al Campagna
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

Scott said:
I would like to automatically change the first letter to upper case and
keep the rest intact of each word on a control of a form. Is there any
functions to do this job?

Thanks,

Scott
 
Scott,
Upon re-reading your post, I see you want to perform that action against any text
control "on the form".
And, reading Fred's response (Thanks Fred), tipped me off to the fact that you weren't
changing just the first letter of the text string, but the first letter of each word.
So...
Private Sub ProperCase_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Value = StrConv(ctl.Value, vbProperCase)
End If
Next
End Sub

This would not work for text like John McNamara (John Mcnamara) or VanDyke (Vandyke)
If necessary, in the future, use that StrConv function on the AfterUpdate event of each
text field to prevent this from becoming a reoccuring problem.
 
Fred,
Thanks Fred... I wish email came with VBA syntax checking... :-D
Actually, upon re-reading Scott's post, I realized he was looking to loop through all
the form's text controls and perform the StrConv on each, so I re-replied with an updated
post.
Al Campagna

Fred Boer said:
Dear Scott, Al:

Al has provided a process to convert the first letter of the string to upper case and
leave the rest of the string unchanged, as in:

the big man > The big man

Scott, you *may* be asking to convert like this (the working of your question is a bit
confusing):

the big man > The Big Man

If so, and if you are talking about a textbox on a form called, say, "txtSomeWords",
then you can use the AfterUpdate event of the control to make this change, like so:

Private Sub txtSomeWords_AfterUpdate()
Me.txtSomeWords = StrConv(Me.txtSomeWords, vbProperCase)
End Sub

If you want to use this process in a query, IIRC, you must use "3" instead of
vbProperCase...

HTH
Fred Boer

P.S. Al, I think there was a typo in your example... I think you meant to write:
UCase(Left(SomeText,1)) & Mid(SomeText,2)

Al Campagna said:
Scott,
Using an Update query to change a field called [SomeText]...
Update To : UCase(Left(SomeText,1) & Mid(SomeText,2)
should do it.
--
hth
Al Campagna
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

Scott said:
I would like to automatically change the first letter to upper case and keep the rest
intact of each word on a control of a form. Is there any functions to do this job?

Thanks,

Scott
 
Hi Al:

You are welcome. I think at this point, there's an answer here whatever the
exact meaning of the question!

Cheers!
Fred

Al Campagna said:
Fred,
Thanks Fred... I wish email came with VBA syntax checking... :-D
Actually, upon re-reading Scott's post, I realized he was looking to loop through all
the form's text controls and perform the StrConv on each, so I re-replied with an updated
post.
Al Campagna

Fred Boer said:
Dear Scott, Al:

Al has provided a process to convert the first letter of the string to upper case and
leave the rest of the string unchanged, as in:

the big man > The big man

Scott, you *may* be asking to convert like this (the working of your question is a bit
confusing):

the big man > The Big Man

If so, and if you are talking about a textbox on a form called, say, "txtSomeWords",
then you can use the AfterUpdate event of the control to make this change, like so:

Private Sub txtSomeWords_AfterUpdate()
Me.txtSomeWords = StrConv(Me.txtSomeWords, vbProperCase)
End Sub

If you want to use this process in a query, IIRC, you must use "3" instead of
vbProperCase...

HTH
Fred Boer

P.S. Al, I think there was a typo in your example... I think you meant to write:
UCase(Left(SomeText,1)) & Mid(SomeText,2)

Al Campagna said:
Scott,
Using an Update query to change a field called [SomeText]...
Update To : UCase(Left(SomeText,1) & Mid(SomeText,2)
should do it.
--
hth
Al Campagna
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

I would like to automatically change the first letter to upper case and keep the rest
intact of each word on a control of a form. Is there any functions to do this job?

Thanks,

Scott
 
AI & Fred,

Many thanks for your useful suggestions and forgive me inaccurate question.

Scott
 

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

Back
Top