I have an textbox which is used to enter peoples first names. I want to change the first character to upper case and all other characters to lower case using vba on the after update event. How can i do this ?
Thanx for the star, but actually I think Bob's code is better. Why:
With strConv using vbpropercase, each word gets a Ucase first letter. So if my first name had been Roy Vidar, typing roy vidar would have produced 'Roy Vidar', but unfortunately my parents put in that '-' thingie which "¤&£ up the whole thing. This might be solved by:
Dim lStart As Long
lStart = InStr(Me!NameOfControl, "-"
If lStart <> 0 Then
Me!NameOfControl = UCase(Mid$(Me!NameOfControl, 1, 1)) & _
LCase(Mid$(Me!NameOfControl, 2, lStart - 1)) & _
UCase(Mid$(Me!NameOfControl, lStart + 1, 1)) & _
LCase(Mid$(Me!NameOfControl, lStart + 2))
Else
Me!NameOfControl = StrConv(Me!NameOfControl, vbProperCase)
End If
This should work with one occurence of '-' in the first name. I've never seen more;-)
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.