enter text and hit enter to go to form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Currently I have a combo box on a form that a user can select from or type an
ID into. Then the user can either click the command button or they can hit
Enter twice (which tabs to the command button and opens it). This takes the
user to a form with data for the ID.

A user wants to be able to type in an ID in the combo box and just hit Enter
once (not hit enter twice and not have to click the command button) to get to
the form.

I can't figure out how to accomplish this. I thought I could just call the
button click event from the combo enter event. This didn't work:
Private Sub cboSAR_ID_Enter()
cmdGoTo_SAR_Click
End Sub

Any suggestions?

Thank you,
Judy
 
It just hit me that the Enter event is on entering the control (not hitting
the Enter button). So now I tried the Exit event for the combo box. It does
take me to the form when I hit enter, but that is not the behavior I want.
There is another button the user can click that also uses the ID. Putting
code in the Exit event makes it so that the user always goes to the data form
and can never click the other button.

Is there any way to "capture" the enter so that it executes the code in the
button click event?
 
I can't figure out how to accomplish this. I thought I could just call the
button click event from the combo enter event. This didn't work:
Private Sub cboSAR_ID_Enter()
cmdGoTo_SAR_Click
End Sub

Any suggestions?

Use the Combo's AfterUpdate event instead.

John W. Vinson[MVP]
 
I didn't mention in my first post that I have a combo box and two command
buttons that use the ID in the combo box.

The button to go to a form is the most commonly used, but I also want the
user to be able to click the button to go to the ID in another application.

If I use the AfterUpdate event of the combo box the user will never be able
to choose the other command button.

The behavior I want after the user enters an ID is to either hit enter to go
to the form (the first command button) or be able to click the second command
button (to follow a hyperlink). Is this possible?

Thank you,
Judy
 
The behavior I want after the user enters an ID is to either hit enter to go
to the form (the first command button) or be able to click the second command
button (to follow a hyperlink). Is this possible?

I'd say to just SetFocus to the first command button in the
afterupdate event (rather than explicitly clicking it).

The AfterUpdate and Exit events both fire when you leave the focus on
the combo box. I don't know if there is a way to distinguish HOW you
selected the entry (hitting Enter, or Tab, or mouseclicking) - one of
the form interaction gurus might but I don't!

John W. Vinson[MVP]
 
I was really hoping this would work. I still have to hit the Enter key twice
to get to the form (hitting Enter the first time takes me from the combo box
to the button, still have to hit Enter again to go to the form).

But thank you for at least trying to help with my dilemma!
Judy
 

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

Back
Top