|
-
Jun 30th, 2003, 09:31 AM
#1
Thread Starter
New Member
key press event
Hi,
I have a spin button on my form and I need it to scroll up/down depending on which key is pressed (pg up/pg dn). I tried the key press event for the spin button by passing the asci code for the keys, but it doesnt seem to work. I am sure this is the way to do it, but I am not getting it right. I need to know where I have to enter the key code for the pg up/ pg dn buttons.
Thanks in advance,
Sunil.
-
Jun 30th, 2003, 09:39 AM
#2
Hyperactive Member
-
Jun 30th, 2003, 09:47 AM
#3
Hyperactive Member
Make sure the forms key preview is set to true and in the key down event the following will work
Code:
if keycode = 33 then 'page up
'your code here
else if keycode = 34 then 'page down
'your code here
endif
-
Jun 30th, 2003, 12:16 PM
#4
Thread Starter
New Member
i cannot find the key preview property...8)
-
Jun 30th, 2003, 12:18 PM
#5
Thread Starter
New Member
heres what I did
Private Sub spnBtn1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 33 Then
EntrytoCell
Set rowno = Cells(ActiveCell.Row - 1, 1)
rowno.Activate
CelltoEntry
Else
If KeyCode = 34 Then
EntrytoCell
Set rowno = Cells(ActiveCell.Row - 1, 1)
rowno.Activate
CelltoEntry
End If
End If
End Sub
-
Jul 2nd, 2003, 02:07 PM
#6
Thread Starter
New Member
key press event(resolved)
well kinda, i tried associating the event with a text box and it worked. so whenever im in the text box and i hit the pgup/pgdn button it loads a new record, only problem is that it is obviously not going to work if the focus is on some other object. i tried the forms key press event, but for some reason the control doesnt seem to go to it, but as long as it works with the text box
Thanks
Sunil.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|