Get/Set Scrollbar

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have been using Steven Leban's SetGetSB code toreturn the user to the row
that they where using, in a continuous form, before a requery. For a DAO
project it works fine. But I have been working on ADP's and ADO and it no
longer works. Does anyone know how to fix the code or have any other code
souce I can look at?
Thanks
 
I'm not intimately familiar with that code, but at a quick glance it appears
to make extensive use of the Form.RecordsetClone.AbsolutePosition property.
In an MDB, Form.RecordsetClone will (normally) return a DAO recordset. In an
ADP, it will return an ADO recordset. The DAO AbsolutePosition property is
zero-based, it returns a value between zero and one less than the number of
records. But the ADO AbsolutePosition property is one-based - it returns a
number between one and the number of records. So in the ADP, the existing
code is likely to be 'off-by-one'. For example, in the cmdReturn_Click event
procedure of the Form_frmSetScrollBarUsingSelTop module, you'll find this
line of code ...

Me.RecordsetClone.AbsolutePosition = Me.CurrentRecord + RowsFromTop - 1

When the current record is the first record, this will return zero. That's a
perfectly valid result in an MDB, where the AbsolutePosition of the first
record is 0. But it is invalid in an ADP, where the AbsolutePosition of the
first record is 1, and there is no 'record 0'.

Modifiying all of the code to take account of this difference is probably
do-able, but probably non-trivial - I'm afraid it's not something that I
could spare the time to do right now. Perhaps the above information may be
enough to enable you to solve the problem yourself. If not, you could send
Stephen an e-mail - his e-mail address is in the comments in the code.
 
Thanks Brendan

Brendan Reynolds said:
I'm not intimately familiar with that code, but at a quick glance it appears
to make extensive use of the Form.RecordsetClone.AbsolutePosition property.
In an MDB, Form.RecordsetClone will (normally) return a DAO recordset. In an
ADP, it will return an ADO recordset. The DAO AbsolutePosition property is
zero-based, it returns a value between zero and one less than the number of
records. But the ADO AbsolutePosition property is one-based - it returns a
number between one and the number of records. So in the ADP, the existing
code is likely to be 'off-by-one'. For example, in the cmdReturn_Click event
procedure of the Form_frmSetScrollBarUsingSelTop module, you'll find this
line of code ...

Me.RecordsetClone.AbsolutePosition = Me.CurrentRecord + RowsFromTop - 1

When the current record is the first record, this will return zero. That's a
perfectly valid result in an MDB, where the AbsolutePosition of the first
record is 0. But it is invalid in an ADP, where the AbsolutePosition of the
first record is 1, and there is no 'record 0'.

Modifiying all of the code to take account of this difference is probably
do-able, but probably non-trivial - I'm afraid it's not something that I
could spare the time to do right now. Perhaps the above information may be
enough to enable you to solve the problem yourself. If not, you could send
Stephen an e-mail - his e-mail address is in the comments in the code.
 

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

Back
Top