Proper Case

  • Thread starter Thread starter APH
  • Start date Start date
A

APH

Someone has sent me a databse with everything in Upper Case. Can someone
tell me what the command is to change this to Capitalized text please

Thanks
A
 
Hi

This function should do what you want/need. SAve this to a module, then to can
call the function up from an Update query.

Maurice


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] = 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.
'
' See Also: StrConv Function in the Microsoft Access 97 online Help.

Dim Temp$, C$, OldC$, i As Integer
If IsNull(x) Then
Exit Function
Else
Temp$ = CStr(LCase(x))
' Initialize OldC$ to a single space because first
' letter needs to be capitalized but has no preceding letter.
OldC$ = " "
For i = 1 To Len(Temp$)
C$ = Mid$(Temp$, i, 1)
If C$ >= "a" And C$ <= "z" And (OldC$ < "a" Or OldC$ > "z") Then
Mid$(Temp$, i, 1) = UCase$(C$)
End If
OldC$ = C$
Next i
Proper = Temp$
End If
End Function
 
Someone has sent me a databse with everything in Upper Case. Can someone
tell me what the command is to change this to Capitalized text please

Thanks
A

I Guess You Mean Like This?

To change any field to proper case in a query:
Exp:strConv([FieldName],3)

If you wish to permanently change the data you must use an Update
query:

Update YourTable Set YourTable.FieldName = StrConv([FieldName],3);

A note of caution. StrConv() changes the first letter of every word to
a capital and all other letters are changed to lower case.
This may sometimes give unwanted results. Names with 2 capitals
(McDonald, O'Connor, IBM, etc.) are changed to Mcdonald, O'connor, and
Ibm, etc., while some names that should be lower case (van Houten, von
Braun) will incorrectly become Van Houten and Von Braun.
 
Back
Top