Input mask problem

  • Thread starter Thread starter Jack Isaacs
  • Start date Start date
J

Jack Isaacs

Hello All
I'm sure this should be simple but I can't seem to get it. I need an input
mask to make it so that the first character of each word entered in a text
box is capitalised, and the rest are lower-case. All characters will be
alpha-numeric, and there will be anything from 1 to 4 'names' - i.e. up to 3
spaces. So the very first character needs to be capitalised, then the first
character after a space needs to be capitalised.
I would be very grateful for any help.
Many thanks
Les
 
Hello All
I'm sure this should be simple but I can't seem to get it. I need an input
mask to make it so that the first character of each word entered in a text
box is capitalised, and the rest are lower-case. All characters will be
alpha-numeric, and there will be anything from 1 to 4 'names' - i.e. up to 3
spaces. So the very first character needs to be capitalised, then the first
character after a space needs to be capitalised.
I would be very grateful for any help.
Many thanks
Les

Input masks have very limited capabilities; this is not amongst them.
You simply cannot do this with an Input Mask.

What you can do is to put VBA code in the textbox's AfterUpdate event,
using the StrConv() function to translate the user's input into Proper
Case (Each Word Capitalized):

Private Sub txtName_AfterUpdate()
' Only convert fields that are not already mixed case
' This will leave correct but not "proper" names such as
' MacDonald, van der Steen, and de Vargas undamaged
If StrComp(Me!txtName, LCase(Me!txtName), 0) = 0 Then
Me!txtName = StrConv(Me!txtName, vbProperCase)
End If
End Sub

John W. Vinson[MVP]
 
Many thanks John - that works a treat!
Les


John Vinson said:
Input masks have very limited capabilities; this is not amongst them.
You simply cannot do this with an Input Mask.

What you can do is to put VBA code in the textbox's AfterUpdate event,
using the StrConv() function to translate the user's input into Proper
Case (Each Word Capitalized):

Private Sub txtName_AfterUpdate()
' Only convert fields that are not already mixed case
' This will leave correct but not "proper" names such as
' MacDonald, van der Steen, and de Vargas undamaged
If StrComp(Me!txtName, LCase(Me!txtName), 0) = 0 Then
Me!txtName = StrConv(Me!txtName, vbProperCase)
End If
End Sub

John W. Vinson[MVP]
 
Back
Top