Subform Navigation >Bump<
Hi All.
I have a data entry subform that is in continuous subform view. I would like the user to be able to use the standard navagation buttons. (Arrow Keys, Enter Keys, Tab, And Page Up and Down)
What is the best way to do this?
Here's What my form looks like:
Here is the code that I wrote to try and handle the arrow keys and the enter keys:
Private Sub Form_MoveNext()
____Dim rst1 As Recordset
____Me.Refresh
____Set rst1 = Me.RecordsetClone
____If Not rst1.EOF Then
________rst1.MoveNext
____End If
____If Not rst1.EOF Then
________Me.Bookmark = rst1.Bookmark
____End If
____rst1.Close
End Sub
Private Sub Form_MovePrevious()
____Dim rst1 As Recordset
____Me.Refresh
____Set rst1 = MeRecordsetClone
____If Not rst1.BOF Then
________rst1.MovePrevious
____End If
____If Not rst1.BOF Then
________Me.Bookmark = rst1.Bookmark
____End If
____rst1.Close
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
____Dim ctl As Control
____Set ctl = Screen.ActiveControl
____If KeyCode = 40 Or (KeyCode = 13 And Shift = 0) Then
________Form_MoveNext
____End If
____If KeyCode = 38 Or (KeyCode = 13 And Shift = 1) Then
________Form_MovePrevious
____End If
____If KeyCode = 39 Or (KeyCode = 9 And Shift = 0) Then
________Select Case ctl.Name
____________Case "Score_Q1": Score_Q2.SetFocus
____________Case "Score_Q2": Score_E1.SetFocus
____________Case "Score_E1": Score_Q3.SetFocus
____________Case "Score_Q3": Score_Q4.SetFocus
____________Case "Score_Q4": Score_E2.SetFocus
________End Select
____End If
____If KeyCode = 37 Or (KeyCode = 9 And Shift = 1) Then
________Select Case ctl.Name
____________Case "Score_Q2": Score_Q1.SetFocus
____________Case "Score_E1": Score_Q2.SetFocus
____________Case "Score_Q3": Score_E1.SetFocus
____________Case "Score_Q4": Score_Q3.SetFocus
____________Case "Score_E2": Score_Q4.SetFocus
________End Select
____End If
End Sub
This causes a few problems. First, when I use the up arrow to go to the top record, and then hit the up arrow again... I have to hit the down arrow twice before it will go to the next record. The same is true with the bottom record and the up arrow.
Second, the page up and page down buttons seem to work, but then when I use the arrow keys, the focus jumps back to the last record that had the focus before the pageup key was used.
Third changing the record using the mouse causes the same effect as the page up and page down buttons.
What am I doing wrong?
Also, how can I insert code into a post without losing my indenting?
-Funger
Hi All.
I have a data entry subform that is in continuous subform view. I would like the user to be able to use the standard navagation buttons. (Arrow Keys, Enter Keys, Tab, And Page Up and Down)
What is the best way to do this?
Here's What my form looks like:

Here is the code that I wrote to try and handle the arrow keys and the enter keys:
Private Sub Form_MoveNext()
____Dim rst1 As Recordset
____Me.Refresh
____Set rst1 = Me.RecordsetClone
____If Not rst1.EOF Then
________rst1.MoveNext
____End If
____If Not rst1.EOF Then
________Me.Bookmark = rst1.Bookmark
____End If
____rst1.Close
End Sub
Private Sub Form_MovePrevious()
____Dim rst1 As Recordset
____Me.Refresh
____Set rst1 = MeRecordsetClone
____If Not rst1.BOF Then
________rst1.MovePrevious
____End If
____If Not rst1.BOF Then
________Me.Bookmark = rst1.Bookmark
____End If
____rst1.Close
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
____Dim ctl As Control
____Set ctl = Screen.ActiveControl
____If KeyCode = 40 Or (KeyCode = 13 And Shift = 0) Then
________Form_MoveNext
____End If
____If KeyCode = 38 Or (KeyCode = 13 And Shift = 1) Then
________Form_MovePrevious
____End If
____If KeyCode = 39 Or (KeyCode = 9 And Shift = 0) Then
________Select Case ctl.Name
____________Case "Score_Q1": Score_Q2.SetFocus
____________Case "Score_Q2": Score_E1.SetFocus
____________Case "Score_E1": Score_Q3.SetFocus
____________Case "Score_Q3": Score_Q4.SetFocus
____________Case "Score_Q4": Score_E2.SetFocus
________End Select
____End If
____If KeyCode = 37 Or (KeyCode = 9 And Shift = 1) Then
________Select Case ctl.Name
____________Case "Score_Q2": Score_Q1.SetFocus
____________Case "Score_E1": Score_Q2.SetFocus
____________Case "Score_Q3": Score_E1.SetFocus
____________Case "Score_Q4": Score_Q3.SetFocus
____________Case "Score_E2": Score_Q4.SetFocus
________End Select
____End If
End Sub
This causes a few problems. First, when I use the up arrow to go to the top record, and then hit the up arrow again... I have to hit the down arrow twice before it will go to the next record. The same is true with the bottom record and the up arrow.
Second, the page up and page down buttons seem to work, but then when I use the arrow keys, the focus jumps back to the last record that had the focus before the pageup key was used.
Third changing the record using the mouse causes the same effect as the page up and page down buttons.
What am I doing wrong?
Also, how can I insert code into a post without losing my indenting?
-Funger
Last edited: