Article ID: 114552
Article Last Modified on 6/13/2001
Option Explicit
Dim rec_count As Integer
Dim rs As Recordset
Sub Form_Load ()
' Find out how many records are in the form.
Set rs = Me.recordsetclone
rec_count = rs.recordcount
' Initialize the scroll bar properties:
Me!scrollbar1.object.Max = rec_count
Me!scrollbar1.object.Min = 0
Me!scrollbar1.object.SmallChange = 1
Me!scrollbar1.object.LargeChange = 5
End Sub
Sub scrollbar1_Change ()
Dim x As Integer
' Moves to the first record in the form's dynaset, then moves
' .. forward x records, x being the value of the scroll bar.
rs.MoveFirst
x = Me!scrollbar1.object.value
rs.Move x
' Check to see if at the beginning or end of the
' .. recordset, and if so, take appropriate action.
If rs.eof Then
rs.MoveLast
End If
If rs.bof Then
rs.MoveFirst
End If
' Coordinate the form bookmark and the dynaset's bookmark.
Me.bookmark = rs.bookmark
End Sub
Sub Form_Current ()
' Reinitialize the rec_count variable in case records are added.
rec_count = rs.recordcount
Me!scrollbar1.object.Max = rec_count
End Sub
Keywords: kbinfo kbusage KB114552