I am trying to pull in a huge recordset from across a network. I would like to be able to pull in a record set and then use it in subsequent queries as I see fit. Here is what I am using. I have taken out any data that I don't think is relevent if you need more just ask.
When I try to reference the rst1 in the second query I am getting a type mismatch error, but I don't know why. Any help you could give would be appreciated. The hardest questions always have the easiest answers.
Code:
Public Function RunSelectQuery(SQLStatement As String)
'Run a select query
Dim DB As Database
Dim Qry As QueryDef
Dim RST As Recordset
Set DB = CurrentDb
Set Qry = DB.CreateQueryDef("", SQLStatement)
Set RST = Qry.OpenRecordset()
Set RunSelectQuery = RST
End Function
Private Function Test()
Dim rst1 As Recordset
Set rst1 = RunSelectQuery("SELECT * FROM transferInfo")
Dim rst2 As Recordset
Set rst2 = RunSelectQuery("SELECT * FROM " & rst1)
End Function