Moving from Top of report to bottom

BrianFawcett

Registered User.
Local time
Today, 07:59
Joined
May 3, 2010
Messages
63
I have writted the code below to allow the user to use the arrow keys to navigate up and down a report. I also want the functionalily so if the user is at the first record and hits the up arrow key they will go to the bottom and vice versa.

I know I need to write code that knows the record numbers and says if at "1" go to last and if at last go to "1', but I am not certain of the code.

Select Case KeyCode
'Up Arrow
Case 38
If Not Me.Recordset.BOF Then
Me.Recordset.MovePrevious
Else: Me.Recordset.MoveEOF
End If
'Down Arrow
Case 40
If Not Me.Recordset.EOF Then
Me.Recordset.MoveNext
Else: Me.Recordset.MoveBOF
End If
End Select
End Sub
progress.gif
 
I have writted the code below to allow the user to use the arrow keys to navigate up and down a report. I also want the functionalily so if the user is at the first record and hits the up arrow key they will go to the bottom and vice versa.

I know I need to write code that knows the record numbers and says if at "1" go to last and if at last go to "1', but I am not certain of the code.

Select Case KeyCode
'Up Arrow
Case 38
If Not Me.Recordset.BOF Then
Me.Recordset.MovePrevious
Else: Me.Recordset.MoveEOF
End If
'Down Arrow
Case 40
If Not Me.Recordset.EOF Then
Me.Recordset.MoveNext
Else: Me.Recordset.MoveBOF
End If
End Select
End Sub
progress.gif

TIP: use the code tags

Code:
Select Case KeyCode
'Up Arrow
  Case 38
       If Not Me.Recordset.BOF Then
            Me.Recordset.MovePrevious
       Else
            Me.Recordset.MoveLast
       End If
'Down Arrow
  Case 40
         If Not Me.Recordset.EOF Then
               Me.Recordset.MoveNext
         Else
               Me.Recordset.MoveFirst
         End If
End Select
 

Users who are viewing this thread

Back
Top Bottom