Slider to move through Records on form

  • Thread starter Rich W via AccessMonster.com
  • Start date
R

Rich W via AccessMonster.com

I need to place a slider control that when i move it up or down it will go
thru the records forward and previous. Does anyone have a process/code to
do this?

Thanks,
Rich
 
G

Graham Mandeno

Hi Rich

Interesting idea - I'd never thought to try it, until I read your question,
that is :)

The following code seems to work:

===================================
Dim fRecordCountChanged As Boolean

Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
fRecordCountChanged = True
End Sub

Private Sub Form_Current()
If fRecordCountChanged Then
Slider1.Max = Me.Recordset.RecordCount
fRecordCountChanged = False
End If
Slider1.Value = Me.CurrentRecord
End Sub

Private Sub Form_Load()
Slider1.Min = 1
Slider1.Max = Me.Recordset.RecordCount
End Sub

Private Sub Slider1_Scroll()
Dim lMove As Long
lMove = Slider1.Value - Me.CurrentRecord
If lMove <> 0 Then
With Me.RecordsetClone
.Move lMove, Me.Bookmark
Me.Bookmark = .Bookmark
End With
End If
End Sub
====================================

Basically it does the following:

1. Sets the Min and Max of the slider when the form opens.

2. Resets the Max after a filter is applied. (This should probably also be
done after inserting or deleting records)

3. Sets the slider value to match the current record if the record is
changed by a means other than the slider.

4. If the slider is moved, calculate the distance moved and scroll the
recordset accordingly.
 
R

Rich via AccessMonster.com

Hi Graham,
I'm using Access2003,. My slider is microsoft slider8. It doesn't have the
event "scroll". It only has:
on updated, on enter, on exit, on got focus, on lost focus.

Where can I put If the slider is moved, calculate the distance moved and
scroll to the
recordset accordingly?

Thanks,
Rich

Graham said:
Hi Rich

Interesting idea - I'd never thought to try it, until I read your question,
that is :)

The following code seems to work:

===================================
Dim fRecordCountChanged As Boolean

Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
fRecordCountChanged = True
End Sub

Private Sub Form_Current()
If fRecordCountChanged Then
Slider1.Max = Me.Recordset.RecordCount
fRecordCountChanged = False
End If
Slider1.Value = Me.CurrentRecord
End Sub

Private Sub Form_Load()
Slider1.Min = 1
Slider1.Max = Me.Recordset.RecordCount
End Sub

Private Sub Slider1_Scroll()
Dim lMove As Long
lMove = Slider1.Value - Me.CurrentRecord
If lMove <> 0 Then
With Me.RecordsetClone
.Move lMove, Me.Bookmark
Me.Bookmark = .Bookmark
End With
End If
End Sub
====================================

Basically it does the following:

1. Sets the Min and Max of the slider when the form opens.

2. Resets the Max after a filter is applied. (This should probably also be
done after inserting or deleting records)

3. Sets the slider value to match the current record if the record is
changed by a means other than the slider.

4. If the slider is moved, calculate the distance moved and scroll the
recordset accordingly.
I need to place a slider control that when i move it up or down it will go
thru the records forward and previous. Does anyone have a process/code
[quoted text clipped - 3 lines]
Thanks,
Rich
 
G

Graham Mandeno

Hi Rich

I used Access 2003 also. The Slider I used was the one in the MS Common
controls library (mscomctl.ocx). In the "Insert ActiveX Control" list it
appears as "Microsoft Slider Control, version 6.0".

I have never heard of "Slider8". What does it say in the properties sheet
under "Class" and "OLE Class"?
--

Graham Mandeno [Access MVP]
Auckland, New Zealand

Rich via AccessMonster.com said:
Hi Graham,
I'm using Access2003,. My slider is microsoft slider8. It doesn't have
the
event "scroll". It only has:
on updated, on enter, on exit, on got focus, on lost focus.

Where can I put If the slider is moved, calculate the distance moved and
scroll to the
recordset accordingly?

Thanks,
Rich

Graham said:
Hi Rich

Interesting idea - I'd never thought to try it, until I read your
question,
that is :)

The following code seems to work:

===================================
Dim fRecordCountChanged As Boolean

Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
fRecordCountChanged = True
End Sub

Private Sub Form_Current()
If fRecordCountChanged Then
Slider1.Max = Me.Recordset.RecordCount
fRecordCountChanged = False
End If
Slider1.Value = Me.CurrentRecord
End Sub

Private Sub Form_Load()
Slider1.Min = 1
Slider1.Max = Me.Recordset.RecordCount
End Sub

Private Sub Slider1_Scroll()
Dim lMove As Long
lMove = Slider1.Value - Me.CurrentRecord
If lMove <> 0 Then
With Me.RecordsetClone
.Move lMove, Me.Bookmark
Me.Bookmark = .Bookmark
End With
End If
End Sub
====================================

Basically it does the following:

1. Sets the Min and Max of the slider when the form opens.

2. Resets the Max after a filter is applied. (This should probably also
be
done after inserting or deleting records)

3. Sets the slider value to match the current record if the record is
changed by a means other than the slider.

4. If the slider is moved, calculate the distance moved and scroll the
recordset accordingly.
I need to place a slider control that when i move it up or down it will
go
thru the records forward and previous. Does anyone have a process/code
[quoted text clipped - 3 lines]
Thanks,
Rich
 
R

Rich via AccessMonster.com

Ole Class = slider
Classer = MSComctlLib.Slider.2

But it doesn't have an onScroll event

Where can I code the scroll event routine?

Thanks,
Rich

Graham said:
Hi Rich

I used Access 2003 also. The Slider I used was the one in the MS Common
controls library (mscomctl.ocx). In the "Insert ActiveX Control" list it
appears as "Microsoft Slider Control, version 6.0".

I have never heard of "Slider8". What does it say in the properties sheet
under "Class" and "OLE Class"?
Hi Graham,
I'm using Access2003,. My slider is microsoft slider8. It doesn't have
[quoted text clipped - 68 lines]
 
G

Graham Mandeno

Hi Rich

Ah, now I see the problem. You are confusing events with properties.

For example, "Current" is a form event, but "OnCurrent" is a form property
specifying the action to take on that event (which could be a macro or a
custom function or an event procedure).

ActiveX controls do not have properties associated with their custom events
and therefore they do not appear in the property sheet. The only action
that can be associated with these events is an event procedure.

So, all you need to do is paste my code for Slider1_Scroll into your form
module and, if necessary, change "Slider1" to the name of your slider
control. You will then see that <Slider name> is selected in the object
dropdown at the top left of your code window, and "Scroll" is in the event
dropdown at the top right.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Rich via AccessMonster.com said:
Ole Class = slider
Classer = MSComctlLib.Slider.2

But it doesn't have an onScroll event

Where can I code the scroll event routine?

Thanks,
Rich

Graham said:
Hi Rich

I used Access 2003 also. The Slider I used was the one in the MS Common
controls library (mscomctl.ocx). In the "Insert ActiveX Control" list it
appears as "Microsoft Slider Control, version 6.0".

I have never heard of "Slider8". What does it say in the properties sheet
under "Class" and "OLE Class"?
Hi Graham,
I'm using Access2003,. My slider is microsoft slider8. It doesn't have
[quoted text clipped - 68 lines]
Thanks,
Rich
 

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

Top