input mask - capitalize first letter?

G

Guest

Is it possible to create an input mask that will automatically capitalize the
first letter of every word in the field? I know it is possible to have an
input mask that says "any letter that follows, make it upper case". I think
I could make that work for me if every entry was the same number of words and
letters but that's unfortunately not the case (no pun intended!).

Is it possible to create an input mask that says "capitalize the first
letter of the field, and then every letter that follows a space"? That would
work for me, I'm just not sure how to go about creating that input mask.
 
D

Douglas J. Steele

It's not possible using an input mask.

You'll need to use the StrConv function (with a conversion argument of
vbProperCase) in the BeforeUpdate event of the text box.
 
G

Guest

Thanks. Sorry, I'm very new to Access: Where do I find this "BeforeUpdate
event of the text box"?
 
D

Douglas J. Steele

Sorry, that have been AfterUpdate, not BeforeUpdate.

Open the form in Design View and select the text box.

Look at the properties of the text box (View | Properties from the menu).

Look for a property named After Update (it'll be on the Events tab, or near
the bottom of the All tab).

Click in the box to the right of the property: you should see a combo box
appear. Select [Event Procedure] for the property, and click on the ellipsis
(...) to the right of the property. That should take you into the VB Editor,
in the midst of a block of code that looks like

Private Sub NameOfTextBox_AfterUpdate()

End Sub

(where NameOfTextBox will be whatever the specific text box is named)

Between those two lines of code, put:

Me!NameOfTextBox = StrConv(Me!NameOfTextBox, vbProperCase)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


grannash said:
Thanks. Sorry, I'm very new to Access: Where do I find this
"BeforeUpdate
event of the text box"?
 
G

Guest

Hi Grannash

To follow on from Douglas' idea of using StrConv. We use the AfterUpdate of
some text boxes (address fields) in case users don't put the address in
correctly.

I don't know the name of your text box so I have called it "TheBox" (change
it to what is really is).


Private Sub TheBox_AfterUpdate()
Me!TheBox = StrConv(Me!TheBox, vbProperCase)
End Sub



Hope this helps

--
Wayne
Manchester, England.



grannash said:
Thanks. Sorry, I'm very new to Access: Where do I find this "BeforeUpdate
event of the text box"?
 
G

Guest

I must be doing something wrong. I'm not sure I have a 'text box'. I have a
field that I've set the format as text. So when I'm in design view, I'm not
sure how to select the 'text box'. Do I just put my cursor in the field?
When I do View|Properties, I get the properties of the table, not the text
box.

Sorry, thanks for your patience!
 
D

Douglas J. Steele

Oh, there's nothing you can do if you're working directly with the tables.
You must use a form to do this.

Realistically, you should never be working directly with the tables.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top