Title Or Proper Case

J

Joseph Meehan

Is there a function or feature to change case to Proper (see Excel)
or Title (see Word) in MS Access ?

UPPER CASE
lower case
Title Case or Proper Case
 
A

Aaron Howe

I might actually be able to help! I had the same query a
few years back - and then I found this:
http://www.mvps.org/access/strings/str0005.htm

******************** 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] = 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$ = 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
'******************* Code End ****************

Hope that's of use!
 
L

Lynn Trapp

StrConv([YourField],vbProperCase) will do that for you. Use
StrConv([YourField],3) in a query.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top