Dec 1 2005, 07:03 PM
I have a number of cmdButtons on a Parent Form that changes the SourceObject of a subform. I would like to give the user the option of using the Right Arrow key to SetFocus on the subform. I know I can do this on each cmdButton using the KeyDown event but what I rather do is create a function to accomplish this so I don't have to code each and every button. My problem is I'm new to creating functions, subs and etc. Could I get someone to lend a hand in accomplishing this, please?
Dec 1 2005, 10:21 PM
Been searching but just not coming up with anything on my own. No one want to take a stab at it?
Dec 1 2005, 11:36 PM
Private Sub Form_Load()
Me.KeyPreview = True
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
MsgBox "Right arrow pressed"
Your code statements
Dec 1 2005, 11:41 PM
The above code works if I place a textbox and command button on a form and press the right arrow.
The message box fired back and the focus move to a command button.
I hope this is what your after.
Dec 1 2005, 11:57 PM
Thanks Mark. That is what I was after.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here