Re: running an event when user presses ENTER from a txt box
- From: "Baz" <bazz@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 21 Sep 2005 08:07:40 +0100
"A C" <no@xxxxx> wrote in message
news:ZD5Ye.13342$iM2.1122584@xxxxxxxxxxxxxxxxxx
> Hello
>
> We have a form with login and password text boxes.
> We would like the user to be able to enter the password and hit ENTER and
> have the system execute the same code as if they had hit the OK button.
>
> I can get this to work using the onKeyDown event and detecting ENTER, but
my
> question is:
>
> How do I detect the value of the text box given that at this stage it is
> still showing as NULL ? ie Access has not yet updated that text box's
value
> as the focus has not yet moved.
>
> I have a workaround (below) but I dont like it, I want focus to stay in
this
> text box and I simply want Acess to pull out the currently entered value
> without changing focus at all.
>
> /code snip
> Private Sub Password_KeyDown(KeyCode As Integer, Shift As Integer)
>
> Select Case KeyCode
>
> ' If user presses ENTER
>
> Case 13
>
> Me.OKButton.SetFocus 'move focus to cement the value into the text box
> *********** I dont want to do this
>
> Call OKButton_Click
>
> End Select
>
>
> End Sub
>
>
> Thanks
> A
>
>
Set the OK button's "Default" property to Yes. Pressing Enter will then
press the button.
.
- References:
- Prev by Date: Re: jpg displays in A2002 but not A97
- Next by Date: weird calendar control behavior??
- Previous by thread: Q: running an event when user presses ENTER from a txt box
- Next by thread: Re: Tabbing through a form fonts alternate from normal test to bold au
- Index(es):