Or use a Async method.
Pulling in or looping thru 25,000 records in order to perform an update, or when displaying 1 record at a time is the wrong method. If you are updating all the records that meet a specified criteria, then use an Action query. If you are only showing one record at a time, then either use a Keyset/Static server side cursor, or, use a client static cursor and pull-in, (open the recordset), based only one record at a time (setting criteria on the recordsets command text to limit the records returned).
For the latter, 2 recordsets would be best:
One rs that uses a server or client side static cursor,on all records, but retrieving only the values for the primary/unique key and, when the user clicks an arror to get the next record - which navvigation is based on this narrow recordset - take the primary key and open a second recordset new using the primary field and value from the first rs as the criteria for the second rs, and then pull in all of the required fields for that one record.
If you need to have the user view 25,000 records, say in a Grid, then use a client side cursor of type static using as an optional parameter the constants:
adCmdText Or adAsyncFetch
as in:
rsADO.CursorLocation = adUseClient
rsADO.CacheSize = 50
rsADO.Open "SELECT * FROM myTable", conn, adOpenStatic, adLockBatchOptimistic, adCmdText Or adAsyncFetch
Set DataGrid1.DataSource = rsADO
Then, what happens first, is the cache will fill up with 50 records, the grid will show these immediately, and then in the back ground, the remaining records will be pulled in and also placed into the grid.
The only problem with all this is if you use an ORDER BY in the command text. Then the records would need to be sorted first, before displaying. Use indexes for this.
You will not be able to get a record count until this is complete. Or more correct to say is: you could get a recordcount with the rsADO.RecordCount method, but anything that you do with the recordset object, before all the records have been retrieved by the process, that causes the cursor to move to the last record (as in the case of rsADO.recordcount) will cause the recordset to first fill with data before you can do anything else, basically cancelling the async processing - the thread that your project is running on will tied up until the recordcount is complete.
Instead, using the Event:
Private Sub rsADO_FetchComplete(ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
Label1.Caption = rsADO.RecordCount
End Sub
Then, once the fetching of all records in done, you will have, and automatically be able to display, a record count.
You also have the following event that you can use:
Private Sub rsADO_FetchProgress(ByVal Progress As Long, ByVal MaxProgress As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
You will also have the possibility to stop the fetching in case the user decides to close the form before all records are retrieved.
This is similar to what you will see in ACCESS when opening a table with thousands of records in the database window.
[/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!