Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Manchester, Gtr Manchester, England
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    sentence case (2000/XP)

    A user has entered some text in all upper case. They now want to format it correctly. I can only find Conversions for Upper, Lower and Proper case in Access (and Excel) whereas Word has something called 'sentence' case where only the first character after a full stop (period) is capitalised. Any ideas how I can do the same thing within Access.?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: sentence case (2000/XP)

    Access doesn't have a Sentence Case function or option, but usually AutoCorrect will take care of changing the first letter in a sentence to upper case. If you want to change existing data (for example imported from another application), you can copy the following function into a module:

    Public Function SentenceCase(varText As Variant) As Variant
    Dim blnUp As Boolean
    Dim i As Long
    Dim c As String
    If IsNull(varText) Then
    SentenceCase = Null
    Else
    blnUp = True
    For i = 1 To Len(varText)
    c = Mid(varText, i, 1)
    If c = "." Then
    blnUp = True
    ElseIf blnUp And Not c = " " Then
    c = UCaseŠ
    blnUp = False
    End If
    SentenceCase = SentenceCase & c
    Next i
    End If
    End Function

    You can use this for example in an update query. It will be slow for large amounts of text.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Manchester, Gtr Manchester, England
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: sentence case (2000/XP)

    Genius <img src=/S/bravo.gif border=0 alt=bravo width=16 height=30>
    Had to convert the text to lower case first but it ran quick enough for my small dataset (a couple of seconds to update about six fields in 300 records).

    Thanks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •