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?
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 = " " 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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.