Going to specific record in recordset

  • Thread starter Thread starter Gibson
  • Start date Start date
G

Gibson

Is there a means to bring up or move to a specific record in a recordset?
Instead of moving to the next or last record I want to move directly to the
second record. Possible?
 
Gibson said:
Is there a means to bring up or move to a specific record in a recordset?
Instead of moving to the next or last record I want to move directly to the
second record.


Two straightforward ways to do that.

You can use:
rs.Move +N
to move forward N records (-N moves back N records)

The other is:
rs.AbsolutePosition = M
to position the recordset to record M
 
Thanks Marshall. Is there a scenerio where this doesn't work? I have a
recordset open and have the line of code
rs.AbsolutePosition = 1
meaning I want to go to the second record in the recordset. After the code
goes through the line I test the absoluteposition and it is still set to 0
and I am still on the first record of the recordset. I am using a DAO
recordset but I had to first open up a querydef and set a parameter before I
opened the recordset, if that matters.

Thanks.
 
You should have received an error if the position wasn't
changed. Do you have On Error Resume Next in you code?

The problem is probably because the recordset has just been
opened and the second record has never been accessed. The
fine print for AbsolutePosition's Help states that you
should use rs.MoveLast to fully populate the recordset
before trying to move beyond the last accessed record.

If that's not your problem, please provide more details
about the dbEngine, recordset type and the code that you are
using.
 
Back
Top