Link to home
Start Free TrialLog in
Avatar of Jeremy Campbell
Jeremy CampbellFlag for United States of America

asked on

How to assign TAB or SHIFT+TAB to an access combo box on a form?

Anyidea what the vba would be to assign TAB or SHIFT+TAB to an access command button?

Thanks!
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

SendKeys "{TAB}" and SendKeys "+{TAB}"

mx
Private Sub btnDoIt_Click()

    SendKeys "{TAB}"   '  Tab
    SendKeys "+{TAB}"    ' Shift + Tab
 
End Sub
Avatar of Jeremy Campbell

ASKER

Yup, that works but didn't think about the fact that by clicking on the button you are taking focus off of the current field.. Not sure how to work through that.

Anyideas how to keep it from losing focus on the current field in the form? (the reason I'm trying to do this is the form is being used on a touch device and I don't want to have to pull up the keyboard to move through the fields)
is there a reason why you want to use Tab or Crtl+Tab to access a command button? You could also assign an hotkey to the button which might be a little easier/cleaner. To do that simple put an ampersand (&) in front of the character that you want to be designated as the hotkey to access the button. For example, if you have a button called btn_Test, and the caption for the button is Test, and you want to access Test without clicking the button, all you need to do is put an ampersand (&) in front of one of the characters in the caption. So, in this example the property for caption would be '&Test' if you wanted T to be the hotkey. Then to access that button without clicking it, all you need to do is press Alt+T.
Not looking for a hotkey to get to a command button. Just want to make a commnd button activate a key combination.
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a bunch! That's perfect!
OH! Sorry, I misunderstood you request.