I have a table in another Excel file from which I use a SQL statement to pull a single matching record

Please Login or Register  to view this content.
In my code I run this SQL statement over and over again with different variables, perhaps 25 or 30 times. Obviously I have to close the recordset and recreate the connection every time.


The other option would be to bring in the entire table once and search the recordset each time.
There would be over 200 records if I brought the entire table into the recordset.

The only way I know of to search through the recordset for the matching row is to LOOP THROUGH, which if it matches on Row 2 is great but not so great if it matches on row 222.

Am I doing this the most efficient way or is there an option I haven’t though of?