From: seeker on
I have a textbox that the user wants to have all caps while he types into the
textbox. The following code is in the onchange event for the textbox.

txtNameKey.Text = UCase(txtNameKey.Text)
txtNameKey.SelStart = Len(txtNameKey) + 1

This takes the textbox back to the first letter and overwrites it. I want
it to type the second letter and then third etc. Thanks.
From: Peter Hibbs on
You could try this in the KeyPress event of the Text box :-

KeyAscii = Asc(UCase(Chr(KeyAscii)))

HTH

Peter Hibbs.

On Sun, 1 Nov 2009 10:30:01 -0800, seeker
<seeker(a)discussions.microsoft.com> wrote:

>I have a textbox that the user wants to have all caps while he types into the
>textbox. The following code is in the onchange event for the textbox.
>
> txtNameKey.Text = UCase(txtNameKey.Text)
> txtNameKey.SelStart = Len(txtNameKey) + 1
>
>This takes the textbox back to the first letter and overwrites it. I want
>it to type the second letter and then third etc. Thanks.
From: Dirk Goldgar on
"seeker" <seeker(a)discussions.microsoft.com> wrote in message
news:7D5AFD76-3481-463B-AF6A-66736FCEBE99(a)microsoft.com...
>I have a textbox that the user wants to have all caps while he types into
>the
> textbox. The following code is in the onchange event for the textbox.
>
> txtNameKey.Text = UCase(txtNameKey.Text)
> txtNameKey.SelStart = Len(txtNameKey) + 1
>
> This takes the textbox back to the first letter and overwrites it. I want
> it to type the second letter and then third etc. Thanks.


I don't think I'd use the Change event for this. How about using the
control's KeyPress event instead, to translate each keystroke as it is
typed:

'------ start of code ------
Private Sub txtNameKey_KeyPress(KeyAscii As Integer)

KeyAscii = Asc(UCase(Chr(KeyAscii)))

End Sub
'------ end of code ------

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)