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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Navigate filtered recordset with PgUp/PgDwn/Home/End

Status
Not open for further replies.

lmarles

Technical User
Dec 8, 2000
25
0
0
CA
Hi,

I have a Data control (datSamples) with RecordSource pointing to the 'Samples' table of my database.

My program creates a filtered recordset from the datSamples.recordset. I can navigate through the filtered recordset using the mouse to click the navigation arrows on the data control.

What I want to do is allow the user to navigate through the filtered recordset using the PageUp/PageDown/Home/End keys.

How can I do this?
 
I would use the Key_Press event. My link I had to an ASCII reference page is broken. But I would find the ASCII value for page up /down, end, etc. And try .movenext when that numerical value is acheived.
 
Its actually Keycode values that you will need.
Keycode values for those keys are:

33 Page Up
34 Page Down
35 End
36 Home
37 Left arrow
38 Up arrow
39 Right arrow
40 Down arrow Let me know if this helps

Check out FAQ222-2244
 
John, where did you get those code numbers? Linkage? I need to print me a list. Thanks.
 
Try this on an empty form, ensuring that you can see the immediate window.
Code:
Private Sub Form_Load()
KeyPreview = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Debug.Print KeyCode
End Sub
Press the key, see the number! Let me know if this helps

Check out FAQ222-2244
 
Thanks all.

I added the following code and it worked.

Private Sub Form_Load()
KeyPreview = True
End Sub

Private Sub Form_KeyDown(keycode As Integer, shift As Integer)
With Me.datSamples.Recordset
Select Case keycode
Case vbKeyPageUp 'Page Up Key Pressed
.MovePrevious
Case vbKeyPageDown 'Page Down Key Pressed
.MoveNext
Case vbKeyEnd 'End Key Pressed
.MoveLast
Case vbKeyHome 'Home Key Pressed
.MoveFirst
End Select
End With
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top