cycling records on form

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi Everyone,

I need to cycle the display of a limited number of records at a time(10
for example), wait a few seconds and display the next 10 reocrds from
the table the form is bound to. When the end of the table is reached,
I'll need to begin at the top of the table.No other activity will occur
on this form, it is merely to cycle through auction items at our
charity auction (being displayed via a LCD projector), allowing bidders
to see if they have won an item.

Any Help would be greatly appreciated.

Thanks,
Mike
 
The following code assumes that the field ItemNumber contains a sequential
number, from 1 to the total number of records. I've displayed 5 records at a
time instead of 10 just so that I could test it with a smaller number of
test records. Set the Timer Interval of the form to the number of
milliseconds you want the subset of records to be displayed.

Private Sub Form_Open(Cancel As Integer)

Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT Count(*) AS Records FROM tblTest")
mlngRecords = rst.Fields("Records")
rst.Close
Me.RecordSource = "SELECT TOP 5 * FROM tblTest ORDER BY ItemNumber"

End Sub

Private Sub Form_Timer()

Static slngRecord As Long

slngRecord = slngRecord + 5
If slngRecord >= mlngRecords Then
slngRecord = 0
Me.RecordSource = "SELECT TOP 5 * FROM tblTest ORDER BY ItemNumber"
Else
Me.RecordSource = "SELECT TOP 5 * FROM tblTest WHERE ItemNumber > "
& slngRecord & " ORDER BY ItemNumber"
End If
Me.Requery

End Sub
 
Back
Top