Identify which row of a recordset I am on?

Centrican

Board Regular
Joined
Dec 20, 2006
Messages
130
Hi all,

I need to find out which row of a very large recordset I am currently on. My connection to the database has failed and I need to reconnect, which will mean starting my code again. Trouble is I don't want to do the upload twice.

If I can find out which row I'm on I can do a loop to miss out all the rows that I've already worked on.

I've tried using cursorlocation but I'm not sure that's working as it says 2 and that can't be right.

Any ideas?
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
What about adding a debug statement like this, just display the immediate window in your code screen and test it

Sub debu()
Debug.Print ActiveCell.Address

End Sub
 
Upvote 0
Are you sure you were actually moving through the recordset when the connection failed? You haven't forgotten to code a .MoveNext, have you? (I do this a lot!)

What does .PerCentPosition return?
 
Upvote 0
Thanks for trying to help guys; unfortunately someone turned the machine off on friday night so it ended up being a moot point. Instead of trying again I fixed the issue that was making it run slowly.

I'd still be interested in figuring out how to do this tho, everything I try returns -1 even when I know it is moving through the recordset.
 
Upvote 0
Are you using DAO/ADO to submit the SQL query and then moving through it using .MoveNext?

If so, as soon as you open the recordset, try doing a .MoveLast immediately followed by a .MoveFirst before you start going through the recordset. (It can take a few moments for a large database.) Does that kick-start .AbsolutePosition into working properly?
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,261
Members
452,901
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top