Connecting Tech Pros Worldwide Help | Site Map

A97 How to force uppercase alpha chars in a textbox on a form?

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 13th, 2005, 12:46 PM
MLH
Guest
 
Posts: n/a
Default A97 How to force uppercase alpha chars in a textbox on a form?

I have a textbox on a form into which an alpha-numeric string
of data is entered. I wish to force the casual user, who would
sometimes use upper case, sometimes not and sometimes MIX
the case - yes, believe it - to use UPPER case only.

I tried running UCASE on the string entered during the textbox's
BeforeUpdate event code. That did nothing but return some error
saying I couldn't do it there - some kind-a-race condition, I dunno -
can't change while updating - whatever!

Can I somehow use textbox's inputmask property to allow only
uppercase alpha-numeric strings 2B entered?

  #2  
Old November 13th, 2005, 12:46 PM
MLH
Guest
 
Posts: n/a
Default Re: A97 How to force uppercase alpha chars in a textbox on a form?

And, if I can not use inputmask to filter out lower-case alpha
chars, can I force a conversion of what's being entered keystroke-
by-keystroke in a keydown event procedure?
  #3  
Old November 13th, 2005, 12:46 PM
Allen Browne
Guest
 
Posts: n/a
Default Re: A97 How to force uppercase alpha chars in a textbox on a form?

Use UCase() in the *AfterUpdate* event of the text box to convert the case.

You can place a > in the Format event of the text box to force the display
(but not stored value) to upper case. Don't do this with memo fields: it
truncates to 255 characters.

It is also possible to use the KeyPress event to alter the KeyAscii to the
upper case version of the entry. You still need the AfterUpdate event as
well, in case the user pastes text in.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MLH" <CRCI@NorthState.net> wrote in message
news:a12of154doj7vb2sd7hubuoh6mcqsff0gv@4ax.com...[color=blue]
>I have a textbox on a form into which an alpha-numeric string
> of data is entered. I wish to force the casual user, who would
> sometimes use upper case, sometimes not and sometimes MIX
> the case - yes, believe it - to use UPPER case only.
>
> I tried running UCASE on the string entered during the textbox's
> BeforeUpdate event code. That did nothing but return some error
> saying I couldn't do it there - some kind-a-race condition, I dunno -
> can't change while updating - whatever!
>
> Can I somehow use textbox's inputmask property to allow only
> uppercase alpha-numeric strings 2B entered?[/color]


  #4  
Old November 13th, 2005, 12:46 PM
MLH
Guest
 
Posts: n/a
Default Re: A97 How to force uppercase alpha chars in a textbox on a form?

Thanks, Allen. Do you recommend I use something like
Me!MyField.Text = UCase(Me!MyField.Text)
or can I just use
Me!MyField = UCase(Me!MyField) ? I tried the former
in the OnLostFocus event code. But, it seemed to generate another
Update event (unwanted).

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx

On Fri, 12 Aug 2005 11:02:47 +0800, "Allen Browne"
<AllenBrowne@SeeSig.Invalid> wrote:
[color=blue]
>Use UCase() in the *AfterUpdate* event of the text box to convert the case.
>
>You can place a > in the Format event of the text box to force the display
>(but not stored value) to upper case. Don't do this with memo fields: it
>truncates to 255 characters.
>
>It is also possible to use the KeyPress event to alter the KeyAscii to the
>upper case version of the entry. You still need the AfterUpdate event as
>well, in case the user pastes text in.[/color]

  #5  
Old November 13th, 2005, 12:46 PM
Allen Browne
Guest
 
Posts: n/a
Default Re: A97 How to force uppercase alpha chars in a textbox on a form?

Don't bother with the Text bit.

You're alergic to the AfterUpdate event? It's the one that runs after a
change, and if there was no change you don't need it.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MLH" <CRCI@NorthState.net> wrote in message
news:8p6of19srjtnqeok24aqirevk9k11e91qt@4ax.com...[color=blue]
> Thanks, Allen. Do you recommend I use something like
> Me!MyField.Text = UCase(Me!MyField.Text)
> or can I just use
> Me!MyField = UCase(Me!MyField) ? I tried the former
> in the OnLostFocus event code. But, it seemed to generate another
> Update event (unwanted).
>
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx
>
> On Fri, 12 Aug 2005 11:02:47 +0800, "Allen Browne"
> <AllenBrowne@SeeSig.Invalid> wrote:
>[color=green]
>>Use UCase() in the *AfterUpdate* event of the text box to convert the
>>case.
>>
>>You can place a > in the Format event of the text box to force the display
>>(but not stored value) to upper case. Don't do this with memo fields: it
>>truncates to 255 characters.
>>
>>It is also possible to use the KeyPress event to alter the KeyAscii to the
>>upper case version of the entry. You still need the AfterUpdate event as
>>well, in case the user pastes text in.[/color][/color]


  #6  
Old November 13th, 2005, 12:46 PM
MLH
Guest
 
Posts: n/a
Default Re: A97 How to force uppercase alpha chars in a textbox on a form?

>Don't bother with the Text bit.
10:4[color=blue]
>
>You're alergic to the AfterUpdate event? It's the one that runs after a
>change, and if there was no change you don't need it.[/color]
Ha! You got me on that one. Yeah, I had so much going on in the
afterupdate event code, I didn't wanna throw more in the mix, if I
could help it. But, I'll try it. I'm sure it'll work. Thx.
  #7  
Old November 13th, 2005, 12:46 PM
Terry Kreft
Guest
 
Posts: n/a
Default Re: A97 How to force uppercase alpha chars in a textbox on a form?

Use the keypress event

Private Sub Text0_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

this will then convert the user input to upper case as they input it.


--
Terry Kreft
MVP Microsoft Access


"MLH" <CRCI@NorthState.net> wrote in message
news:a12of154doj7vb2sd7hubuoh6mcqsff0gv@4ax.com...[color=blue]
> I have a textbox on a form into which an alpha-numeric string
> of data is entered. I wish to force the casual user, who would
> sometimes use upper case, sometimes not and sometimes MIX
> the case - yes, believe it - to use UPPER case only.
>
> I tried running UCASE on the string entered during the textbox's
> BeforeUpdate event code. That did nothing but return some error
> saying I couldn't do it there - some kind-a-race condition, I dunno -
> can't change while updating - whatever!
>
> Can I somehow use textbox's inputmask property to allow only
> uppercase alpha-numeric strings 2B entered?[/color]


  #8  
Old November 13th, 2005, 12:47 PM
David W. Fenton
Guest
 
Posts: n/a
Default Re: A97 How to force uppercase alpha chars in a textbox on a form?

MLH <CRCI@NorthState.net> wrote in
news:8p6of19srjtnqeok24aqirevk9k11e91qt@4ax.com:
[color=blue]
> Do you recommend I use something like
> Me!MyField.Text = UCase(Me!MyField.Text)
> or can I just use
> Me!MyField = UCase(Me!MyField) ? I tried the former
> in the OnLostFocus event code. But, it seemed to generate another
> Update event (unwanted).[/color]

Well, you either need to test for IsNull() and not do it, or
concatenate the field with a zero-length string, or this will error
out any time the field is Null.

Either:

Me!MyField = UCase(Me!MyField & vbNullString)

Or:

If Not Isnull(Me!MyField) Then
Me!MyField = UCase(Me!MyField)
End If

In my code, most often I want to do nothing at all in the
AfterUpdate event when the value has been deleted, so I just exit
the sub, rather than repeatedly testing:

If Isnull(Me!MyField) Then Exit Sub
[whatever you'd do if it's not null]

But I can conceive of things that you might want to do in
AfterUpdate if a field is Null, so that isn't always the case.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
  #9  
Old November 13th, 2005, 12:47 PM
MLH
Guest
 
Posts: n/a
Default Re: A97 How to force uppercase alpha chars in a textbox on a form?

This sounds good. I'll give it a shot.
[color=blue]
>Use the keypress event
>
>Private Sub Text0_KeyPress(KeyAscii As Integer)
> KeyAscii = Asc(UCase(Chr(KeyAscii)))
>End Sub
>
>this will then convert the user input to upper case as they input it.[/color]

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.