Re: Keeping The Focus From Changing. How?
- From: "Iain King" <iainking@xxxxxxxxx>
- Date: 31 Aug 2005 03:38:17 -0700
Doug Glancy wrote:
> abxy
>
> You need a global variable to track whether enter was pressed. If it was,
> then do the actions as Tom described, else behave normally, i.e., you can
> click or tab out of the textbox:
>
> Dim enter_pressed As Boolean ' this is above all subroutines
> Option Explicit
> Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
> If enter_pressed Then 'if it was set in the keydown event below
> Cancel = True
> Me.TextBox1 = ""
> enter_pressed = False 'clear it, so back to normal behavior
> End If
> End Sub
>
> Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
> Shift As Integer)
> If KeyCode = 13 Then ' enter key
> enter_pressed = True
> End If
> End Sub
>
> >
or more simply, just put the code you want to run when enter is pushed
in the KeyDown event.
Iain
.
- Follow-Ups:
- Re: Keeping The Focus From Changing. How?
- From: Doug Glancy
- Re: Keeping The Focus From Changing. How?
- References:
- Keeping The Focus From Changing. How?
- From: abxy
- Re: Keeping The Focus From Changing. How?
- From: Tom Ogilvy
- Re: Keeping The Focus From Changing. How?
- From: abxy
- Re: Keeping The Focus From Changing. How?
- From: abxy
- Re: Keeping The Focus From Changing. How?
- From: Doug Glancy
- Keeping The Focus From Changing. How?
- Prev by Date: Re: User-changeable paths into Excel - avoid hard coding
- Next by Date: specific cell
- Previous by thread: Re: Keeping The Focus From Changing. How?
- Next by thread: Re: Keeping The Focus From Changing. How?
- Index(es):
Relevant Pages
|