1. Proper Case

Would anybody be interested in a Function that changes upper case to proper case and takes care of names like McDonald, O'Meara, John Paul III, etc?

2. Re: Proper Case

You might want to post this in the VB/VBA forum. There are a few folks there who are quite interested in functions of the sort. (Not to mention any names....cough...cough...Chris Greaves...cough...cough <img src=/S/wink.gif border=0 alt=wink width=15 height=15>)

3. Re: Proper Case

Post it, and they will come.

4. Re: Proper Case

Helen Fedemma wrote a very good column in todays Woody's Access Watch about this subject. You can download an excerpt from her web page go to <A target="_blank" HREF=http://www.helenfeddema.com/access.htm>this site</A> and download Archon Column # 82 at the bottom.

5. Re: Proper Case

Public Function Proper(anyValue As Variant) As Variant
' Accepts: a text value
' Purpose: converts first letter of each word to uppercase
' Returns: converted text value

Dim i As Integer
Dim theString As String
Dim currChar As String
Dim prevChar As String
Dim prevChar2 As String
Dim prevChar3 As String

If IsNull(anyValue) Then
Exit Function
End If

currChar = " "
prevChar = " "
prevChar2 = " "
prevChar3 = " "

theString = CStr(anyValue)
For i = 1 To Len(theString) 'Go through string char by char.
currChar = Mid(theString, i, 1) 'Get the current character.

Select Case prevChar 'If previous char is letter,
'this char should be lowercase.
Case "I"
If currChar = "I" And (prevChar2 = " " Or prevChar2 = "I") Then
Mid(theString, i, 1) = UCase(currChar)
Else
Mid(theString, i, 1) = LCase(currChar)
End If
Case "c"
If i = 3 And prevChar2 = "M" Then
Mid(theString, i, 1) = UCase(currChar)
Else
Mid(theString, i, 1) = LCase(currChar)
End If
Case "'"
If currChar = "s" Then
mid(theString, i, 1) = LCase(currChar)
End If
Case "A" To "Z", "a" To "z"
Mid(theString, i, 1) = LCase(currChar)

Case Else
Mid(theString, i, 1) = UCase(currChar)

End Select
prevChar3 = prevChar2
prevChar2 = prevChar
prevChar = currChar

Next i
Proper = CVar(theString)

End Function

6. Re: Proper Case

Cool, you can also find similar code at <A target="_blank" HREF=http://www.mvps.org/access/>http://www.mvps.org/access/</A>

Posting Permissions

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