I want the data in text fields displayed in sentence case

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want the data in a clients file to appear as "Peter " ie sentence case
 
Per Smokey smith:
I want the data in a clients file to appear as "Peter " ie sentence case

What data? Each word?

If so,

StrConv("the quick red fox.", vbProperCase)==> "The Quick Red Fox."
 
Thank you for your prompt reply
Peter

(PeteCresswell) said:
Per Smokey smith:

What data? Each word?

If so,

StrConv("the quick red fox.", vbProperCase)==> "The Quick Red Fox."
 
True Sentence Case where only the first letter in a sentence is capitalized
would need a custom function. Something like:

Function SentenceCase(strIn As String)
Dim i As Integer
Dim j As Integer
Dim x As Integer

SentenceCase = strIn
x = Len(strIn)
Mid(SentenceCase, 1, 1) = UCase(Mid(SentenceCase, 1, 1))
For i = 1 To x
If Mid(SentenceCase, i, 1) = "." Then
For j = i + 1 To x
If Mid(SentenceCase, j, 1) <> " " Then
Mid(SentenceCase, j, 1) = UCase(Mid(SentenceCase, j, 1))
Exit For
End If
Next
i = j
End If
Next

End Function
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Arvin,
Your custom funtion for sentence case worked really well for me, I've spent
a long time trying to find an already existing one in Access but couldn't and
finally decided to browse the online help forum.

BTW, my original string started off as all uppercase so I made one small
addition to your code (see below in all caps)
Thanks again for posting this, it has saved me hours of time.
Marco
Function SentenceCase(strIn As String)
Dim i As Integer
Dim j As Integer
Dim x As Integer

SENTENCECASE = LCASE(SENTENCECASE)
 
Unfortunately, that still leaves a problem. If you convert everything to
lower case first, certain things that should be left capitalized won't be: I
will be i and I've will be i've, etc. I suggest converting to lower case,
running my function, then checking for characters that need to be
capitalized.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Marco Brilo said:
Arvin,
Your custom funtion for sentence case worked really well for me, I've
spent
a long time trying to find an already existing one in Access but couldn't
and
finally decided to browse the online help forum.

BTW, my original string started off as all uppercase so I made one small
addition to your code (see below in all caps)
Thanks again for posting this, it has saved me hours of time.
Marco
Function SentenceCase(strIn As String)
Dim i As Integer
Dim j As Integer
Dim x As Integer

SENTENCECASE = LCASE(SENTENCECASE)
 

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