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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Proper Case

Status
Not open for further replies.

umberto

Programmer
Oct 31, 1999
2
US
What is the code for converting all lower case or all upper case into 1st letter capitalize in a form. Also, will this store the data in a table in proper case format?
 
Access has a built in function for this: StrConv(string, vbProperCase).
 
Option Compare Database<br>
Option Explicit<br>
<br>
Public Function CapAllFirst(FValue)<br>
'Capitalize the first letter of all words in a field value and convert<br>
' all other letters to lowercase<br>
Dim Here, NewValue As String<br>
Dim Spot As Integer, Wordstart As Boolean<br>
Wordstart = True<br>
NewValue = CStr(FValue)<br>
For Spot = 1 To Len(FValue)<br>
Here = Mid(NewValue, Spot, 1)<br>
If Here = &quot; &quot; Then<br>
Wordstart = True<br>
Else<br>
If Wordstart Then<br>
Mid(NewValue, Spot, 1) = UCase(Mid(NewValue, Spot, 1))<br>
Wordstart = False<br>
Else<br>
Mid(NewValue, Spot, 1) = LCase(Mid(NewValue, Spot, 1))<br>
End If<br>
End If<br>
Next Spot<br>
CapAllFirst = NewValue<br>
End Function<br>
<br>
This is also a Module that will Capitalize the first letter of a text Box, then all you have to do is under AfterUpdate for a text box to put for example CapAll(State). This would capitalize the first letter for the state under the state AfterUpdate property.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top