[mso] Re: Access Reports & Capitalisation

  • From: "Colli, Anthony G" <Anthony.Colli@xxxxxxx>
  • To: <mso@xxxxxxxxxxxxx>
  • Date: Fri, 25 Jul 2003 09:25:43 -0400

Ben-

This function, in combination with the Proper(X) function will help you.

        TrimSpace("JOHN DOE") will return "John"
        TrimSpace("JOHN JAMES DOE") will return "John"
        TrimSpace("John Doe") will return "John"

-Anthony


*****************************************************
Public Function TrimSpace(ByVal strIn As String) As String
Dim strTemp As String
Dim X As Integer

strIn =3D Trim(strIn)

X =3D InStr(1, strIn, " ")

strTemp =3D LCase(Trim(Left(strIn, X)))

TrimSpace =3D Proper(strTemp)

End Function
**********************************************************
-----Original Message-----
From: Ben Wilson Mawer [mailto:ben.wilson-mawer@xxxxxxxxxxxxxx]
Sent: Friday, July 25, 2003 6:26 AM
To: mso@xxxxxxxxxxxxx
Subject: [mso] Re: Access Reports & Capitalisation



Right well i've found some code on the Accessweb See below,
http://www.mvps.org/access/strings/str0001.htm, web-site which will
capitalise the start of words, just not sure how to pick out only the =
first
word...

I'll keep looking!! :D

Ben

******************* Code Begin ****************
Function Proper(X)
' Capitalize first letter of every word in a field.
' Use in an event procedure in AfterUpdate of control;
' for example, [Last Name] =3D Proper([Last Name]).
' Names such as O'Brien and Wilson-Smythe are properly capitalized,
' but MacDonald is changed to Macdonald, and van Buren to Van Buren.
' Note: For this function to work correctly, you must specify
' Option Compare Database in the Declarations section of this module.
Dim Temp$, C$, OldC$, i As Integer
    If IsNull(X) Then
        Exit Function
    Else
        Temp$ =3D CStr(LCase(X))
        ' Initialize OldC$ to a single space because first
        ' letter needs to be capitalized but has no preceding letter.
        OldC$ =3D " "
        For i =3D 1 To Len(Temp$)
            C$ =3D Mid$(Temp$, i, 1)
            If C$ >=3D "a" And C$ <=3D "z" And _
                (OldC$ < "a" Or OldC$ > "z") Then
                    Mid$(Temp$, i, 1) =3D UCase$(C$)
            End If
            OldC$ =3D C$
        Next i
        Proper =3D Temp$
    End If
End Function
'******************* Code End ****************







*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in 
the subject line.

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts: