Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keep track of RS!!!

Status
Not open for further replies.

aw23

Programmer
Nov 26, 2003
544
IL
I have a complex search and then I load the results into a listbox. There can be thousands of results and this is problematic. So I created a field where the user selects how many results he'd like to view. 200, 400, 1000, etc.
Now lets say the user selcts 200. Afterwards he wants to see the next 200. I can create a button that says "Display next 200 Results" The problem is how can I do this? The rs is already closed! I can leave it open but then at what point do I close it? I can reopen it but then how can I know what record they are up to? What if they press that button 4 times? Is there a simple way to keep track of this? Any suggestions?
Thanks
 
Do you have any kind of sequential identifier (UID) on any of the tables involved in your query? If so, you could assign the UID to a global (make it a long) or even a hidden field on your form (Default of zero). In your criteria for the query, include this field and apply criteria ">lngNewGlobal". When the use clicks "Next 200", update the global or hidden field and requery your list box. You should be able to limit the number of query results to 200, 400 etc. within the query properties.
 
I should have mentioned that you should capture the max UID to update to the global or hidden form.
 
Recordsets have an absoluteposition property, that despite the name, is the relative position of a record in a current recordset, based on which records are present/sort order etc. If you can save that after populating with the last row (200?), then you can try for instance:

[tt]rs.absoluteposition = 200[/tt]

Then loop from there and forward. This is a bit theoretical, but so is the question, since we don't know how you populate;-)

Just a short note, the DAO absoluteposition starts at 0 (first record) while the ADO .absoluteposition starts at 1. I think you'll need a client side cursor for ADO, and for DAO you'll need to fully populate the recordset prior to assigning av value larger than 0 (movelast)

Roy-Vidar
 
Thanks! I actually figured it out. I used tags to store the number and I used rs.absoluteposition.
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top