Help with KeyDown function (1 Viewer)

ShaneMan

Registered User.
Local time
Yesterday, 18:21
Joined
May 9, 2005
Messages
1,224
I've posted this on a couple other forums with no nibbles. Anyone here wanna lend a hand?

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?

TIA,
Shane
 

Oldsoftboss

AWF VIP
Local time
Today, 11:21
Joined
Oct 28, 2001
Messages
2,499
In access help look up Sendkeys. It explains how to create a macro that will carry out custom keystroke events.

HTH

Dave
 

Oldsoftboss

AWF VIP
Local time
Today, 11:21
Joined
Oct 28, 2001
Messages
2,499
Sorry, I just had a look and it doesn't help much at all (surprise surprise).
I will dig around and see if I have an old sample here.

Dave
 

ShaneMan

Registered User.
Local time
Yesterday, 18:21
Joined
May 9, 2005
Messages
1,224
Thanks Boss,

Was able to get an answer:

Public Sub Keycheck(KeyCode)

If KeyCode = 39 Then
Me.subLists.SetFocus
End If

End Sub

Curious thing (for me any way) is that I can do a Call Keycheck(Keycode) in the Event Procedure for On Key Down and it will work, however if I type:
=Keycheck() @ the event for On Key Down, it will not work. Fires an error msg stating function must be by a different name. Any idea's why?

Thanks again,
Shane
 

Users who are viewing this thread

Top Bottom