G
Guest
I have created a recordset (rstSQL) in VBA. Later in the program, I want to
put this recordset into a table (tblResult). I would like to know if there
is a more efficient way to do this than the "brute force" method:
Set rstTable = db.OpenRecordset("tblResult")
Do While rstSQL.EOF = false
rstTable.AddNew
rstTable("Field1") = rstSQL("Filed1")
.... (repeat for all fields) ...
rstTable.Update
rstSQL.MoveNext
Loop
I would like to do something more elegant, like this:
newSQL = "Select * INTO tblResult from rstSQL"
DoCmd.RunSQL newSQL
However, mixing objects in an SQL string doesn't work.
Any ideas? Or is my initial looping code as good as it gets?
Thanks,
George
put this recordset into a table (tblResult). I would like to know if there
is a more efficient way to do this than the "brute force" method:
Set rstTable = db.OpenRecordset("tblResult")
Do While rstSQL.EOF = false
rstTable.AddNew
rstTable("Field1") = rstSQL("Filed1")
.... (repeat for all fields) ...
rstTable.Update
rstSQL.MoveNext
Loop
I would like to do something more elegant, like this:
newSQL = "Select * INTO tblResult from rstSQL"
DoCmd.RunSQL newSQL
However, mixing objects in an SQL string doesn't work.
Any ideas? Or is my initial looping code as good as it gets?
Thanks,
George