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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for Specific Recordsets

Status
Not open for further replies.

Sorrells

Programmer
Dec 28, 2000
92
US
I have a form with about 10 recordsets. Of them 7 are named rstTemp_1, rstTemp_2 on to rstTemp_7. They are temporary RowSources for listboxes in the form.

In using the form, one, two up to all of the listboxes may have data placed in them. I am looking for a method to loop through all the open recordsets for a match to the string "rstTemp_" so that I can then check it for data and if present, manipulate it.

I've run across two MS Access97 Help examples but in my class module, Access gives me an error and I can understand because in the examples the recordset are dimensioned but not set. The Access code snippet is like this:

Dim dbs As Database, rst As Recordset

For Each rst In dbs.Recordsets
Debug.Print rst.Name; " "; rst.Updatable
Next rst

My test code is as follows:
Dim rstLoop As Recordset
For Each rstLoop In dbs.Recordsets
If Left(rstLoop.name, 8) = "rst_Temp" Then
Debug.Print rstLoop.name
End If
Next rstLoop

Interestingly, I don't get an error, the FOR statement is executed and the entire IF statement is jumped.

I welcome any advice offered.
Regards, Sorrells
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top