AutomatingForm Display

G

Guest

I am using a Form to display the results of a query,and the use the following
code to step through the records when triggered by the on timer property of
the form.
Private Sub Form_Timer()

DoCmd.GoToRecord , "", acNext
If fldName = "LastRec" Then
DoCmd.GoToRecord , "", acFirst



End If
End Sub
Because of the size of the recordset I would like to step 20 records on each
trigger.
Can anyone suggest a method.
Thanks
 
G

Guest

Mybe there is a better way of doing it, but you can try

Private Sub Form_Timer()
Dim I as Integer
For I =1 To 20
DoCmd.GoToRecord , "", acNext
If fldName = "LastRec" Then
DoCmd.GoToRecord , "", acFirst
End If
Next I

End Sub
 
J

Jeff Boyce

Dave

If you are saying you'd like to jump 20 records each time the timer
triggers, a "brute force" way to do that would be to run the GoToRecord 20
times. You could use a For...Next loop to do that.

However, a little research (and a little subtlty) offers a more elegant
solution.

Check Access HELP for "GoToRecord" when you're in the Visual Basic Editor.
You'll find the syntax for this command to include a setting for "Offset",
allowing you to jump 20 records WITHOUT resorting to a loop.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Form Display 1
On Error Problem 3
Update Open Form 3
Problem DoCmd.GoToRecord with tabbed pages 1
use error handling to assign value 4
Send Email 2
error 2499 9
parameter in combobox 2

Top