add a scroll bar - use this as your slider
add four buttons
btnFirst '|<'
btnPrev '<'
btnNext '>'
btnLast '>|
add a horizontal scrollbar
sbSlider
add a label
lblRecordNumber SpecialEffect:=2 - sunken
add this code
Option Explicit
Private Record As Long
Private LastRecord As Long
Private Sub UserForm_Initialize()
'' populates key data
'for this demo
Record = 1
LastRecord = 100
With sbSlider
.Min = 1
.Max = LastRecord
.SmallChange = 1
.LargeChange = 10
End With
End Sub
Private Sub btnFirst_Click()
Record = 1
GetData
End Sub
Private Sub btnLast_Click()
Record = LastRecord
GetData
End Sub
Private Sub btnNext_Click()
If Record < LastRecord Then
Record = Record + 1
GetData
End If
End Sub
Private Sub btnPrev_Click()
If Record > 1 Then
Record = Record - 1
GetData
End If
End Sub
Private Sub sbSlider_Change()
Record = sbSlider.Value
GetData
End Sub
Private Sub GetData()
sbSlider.Value = Record
'''load data for Record
lblIRecordNumber.Caption = Record
End Sub
This demo shows the selected record number in the label.
It shows how to test for the first & last, and it sets
the value of the scrollbar according to the record buttons
The GetData procedure simply places the record number
into the label. It should quite easy to add boxes for
other data & use this to populate them
Use the form's initialise procedure to set up the min,
max etc as I have done.
demo file available - email me directly
Patrick Molloy
Microsoft Excel MVP