In the past, I've always generated reports by querying a database, dropping it on a worksheet, sorting, reading into an array, and then looping through to create the documents. What I'm trying to do now is generate the reports directly from the recordset.
The problem I have though is when using arrays I had an absolute record number, so I could check if a field in the previous record was the same as in the current record.
What is the best way of going about doing this with a recordset? Store the field value in a variable? Use nested While loops? Get a total record count and use absolute positions to move back and forth (which doesn't seem like a good idea)?
UPDATE The recordset contains multiple records from 20 different companies. I sort the query by the company name and then start loop through it. I then need to check each record to see if it's from the same company as the previous and if not create a new worksheet for that company.
currentCompany
. In each iteration on the Recorset, justif rs.fields("company") <> currentCompany then ...create new WS
– A.S.H