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

Jarred Meyer
Jarred Meyer used Ask the Experts™
on
Anyidea what the vba would be to assign TAB or SHIFT+TAB to an access command button?

Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
SendKeys "{TAB}" and SendKeys "+{TAB}"

mx
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
Private Sub btnDoIt_Click()

    SendKeys "{TAB}"   '  Tab
    SendKeys "+{TAB}"    ' Shift + Tab
 
End Sub
Jarred MeyerProduction Manager

Author

Commented:
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)
11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

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.
Jarred MeyerProduction Manager

Author

Commented:
Not looking for a hotkey to get to a command button. Just want to make a commnd button activate a key combination.
Database Architect / Application Developer
Top Expert 2007
Commented:
Private Sub btnDoIt_Click()
    Screen.PreviousControl.SetFocus
    SendKeys "{TAB}"   '  Tab
    SendKeys "+{TAB}"    ' Shift + Tab
 
End Sub
Jarred MeyerProduction Manager

Author

Commented:
Thanks a bunch! That's perfect!
OH! Sorry, I misunderstood you request.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
You are welcome ...

mx

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial