Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Proper Case in Access Query

Status
Not open for further replies.

wandan

Technical User
Dec 16, 2001
101
US
I am trying to convert a field from UPPERCASE LETTERS to Proper Letters when running a query in Access. Is there an easy way to do this?
 
Look up the STRCONV function in help.... Terry
**************************
* General Disclaimor - Please read *
**************************
Please make sure your post is in the CORRECT forum, has a descriptive title, gives as much detail to the problem as possible, and has examples of expected results. This will enable me and others to help you faster...
 
Not sure what function you are using, but you can either use the StrConv function or a Proper function. Either way, you need to use them in your query. e.g. StrConv([FieldName]) or Proper([FieldName] Have a look at the help for StrConv. Here is a Proper Function.

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$ >= &quot;a&quot; And c$ <= &quot;z&quot; And (OldC$ < &quot;a&quot; Or OldC$ > &quot;z&quot;) Then
Mid$(Temp$, I, 1) = UCase$(c$)
End If
OldC$ = c$
Next I
Proper = Temp$
End If
End Function

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top