Input mask to uppercase first letter of names when hyphenated

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to know how to make the first letter uppercase on a name field, but
still be able to input a hyphen or another capital letter such as names like
McPhail.
 
try this code, put it on the on exit of the field you want to change

Dim I As Integer
Dim MyCount As Integer
Dim UserName As String
MyCount = 0
For I = 1 To Len(Me.FieldName)
If MyCount <> 0 Then
UserName = UserName & Mid(Me.FieldName, I, 1)
Else
UserName = UserName & Format(Mid(Me.FieldName, I, 1), ">")
End If
MyCount = 1
If Mid(Me.FieldName, I, 1) = " " Then
MyCount = 0
End If

Next I
Me.FieldName.Value = UserName
 
Back
Top