On Tue, 20 Apr 2010 19:41:01 -0700, Zee
That's pretty straightforward. I created a ContinuousForm based on the
Customers table in the Northwind sample app, and added the following:
Private Sub ID_KeyDown(KeyCode As Integer, Shift As Integer)
HandleKeyDown Me.ID, KeyCode, Shift
End Sub
Private Sub Company_KeyDown(KeyCode As Integer, Shift As Integer)
HandleKeyDown Me.Company, KeyCode, Shift
End Sub
Private Sub HandleKeyDown(ctl As Control, KeyCode As Integer, Shift As
Integer)
If KeyCode = vbKeyUp And Shift = 0 Then
RunCommand acCmdRecordsGoToPrevious
ctl.SetFocus
ElseIf KeyCode = vbKeyDown And Shift = 0 Then
RunCommand acCmdRecordsGoToNext
ctl.SetFocus
End If
End Sub
So for the ID and Company controls I'm handling KeyDown event and
calling my private HandleKeyDown procedure. In it, I am testing for
the KeyUp and KeyDown keycodes signifying CursorUp and CursorDown, and
I am checking that no shift, control, or alt key was down at the same
time. Then I simply move to the previous or next record, and set focus
to my control.
I leave up to you to handle possible errors trying to move up from the
first row or down from the last row.
-Tom.
Microsoft Access MVP
.