Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keystroke/Mouse scroll events - assigning a procedure 1

Status
Not open for further replies.

jojones

Programmer
Dec 4, 2000
104
0
0
AU
I have created a db. The main form's Record Cycle is Current Record. However, when you press PgDn, PgUp, or use the scroll button on a new mouse, it runs through all the records. Is there anyway to capture this key press or mouse scroll event and assign a procedure to it? I have tried to read the help on Key Down, Key Up and Key Press but still don't understand what to do, and there doesn't seem to be an ANSI code assigned to PgUp and PgDn.

Hope someone can help.

Thanks
Jo
 
Hi,
Here is the code...

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If (KeyCode = vbKeyPageDown) Then
MsgBox "Do Something else!"
KeyCode = 0
End If
End Sub

Lookup KeyCode in your help to get the other KeyCode constants... then change the IF statement to a SELECT CASE/SWITCH statement.

Rob Marriott
rob@career-connections.net
 
Oh... first set your form's "Key Preview" property to "Yes" under the "Event" tab in the properties window.

Rob Marriott
rob@career-connections.net
 
Thanks Rob - that's fantastic - but this doesn't work for the mouse scroll. Any ideas??

Jo
 
Sorry, I don't know anything about that event - I think that the scroll button is just a macro built into the hardware. When you move the scroll button the database quickly navigates through all of the records - I would be interested in finding out how to prevent this.

Rob Marriott
rob@career-connections.net
 
Thanks Rob - I will let you know when (hopefully) I find out.

Cheers
Jo
 
very helpful. I used Rob's code in a process to prevent the user from using the tab key to transmit to the next record on my form. I just replaced the vbKeyPageDown with vbKeyTab on the final tab stop.
 
There's a solution to the mouse wheel problem that involves creating a dll in VB. This is Microsoft's solution (you'd think they would have addressed this in the application itself). I'm sorry--I don't have the KB link, but if you search for Mousewheel under Access you should find it.
 
Here's the KB # for the article on capturing the mousewheel event:

Q278379
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top