Results 1 to 5 of 5

Thread: Sentence Case

  1. #1
    Join Date
    Jan 2004
    Posts
    44

    Unanswered: Sentence Case

    Hi there,

    Is there a way of formatting a text field so that the value changes to Sentence Case.

    i.e. mrs K j smith

    to be:

    Mrs K J Smith

    Thanks

  2. #2
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Re: Sentence Case

    No idea about a function like that. A complex way of do it is to take the first letter of each word (playing with "split" and "left") and then use the UCase for this letters.

    Sorry, I am not keen on string functions, but I've tried it.

  3. #3
    Join Date
    Apr 2004
    Location
    South Arica
    Posts
    125
    Paste this code in the after_update event of your text box.

    Dim strCurrent As String
    Dim strTemp As String
    Dim I As Integer

    strTemp = ""
    If IsNull(Text1) Then
    Exit Sub
    Else
    strCurrent = Text1
    End If
    For I = 1 To Len(strCurrent)
    If I = 1 Then
    strTemp = UCase(Mid(strCurrent, 1, 1))
    Else
    If Asc(Mid(strCurrent, I, 1)) = 32 Then
    I = I + 1
    strTemp = strTemp & " " & UCase(Mid(strCurrent, I, 1))
    Else
    strTemp = strTemp & Mid(strCurrent, I, 1)
    End If
    End If
    Next I
    Text1 = strTemp

    I have tested it, and it works fine, not sure if it is the best method though...

  4. #4
    Join Date
    Dec 2002
    Location
    Glasgow, UK
    Posts
    100
    if you have access2k or above you can use the strconv function:


    ie

    strconv("mRs k J sMith",vbprobercase)

    this will return "Mrs K J Smith"
    Access XP & WinXP Pro

  5. #5
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    Originally posted by xander
    if you have access2k or above you can use the strconv function:


    ie

    strconv("mRs k J sMith",vbprobercase)

    this will return "Mrs K J Smith"
    Just a quick note for the person he's answering...
    vbProperCase vs. vbprobercase

Posting Permissions

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