Copy a Recordset???

T

Tlm

Hello All,



I'm trying to something I thought would be very simple - copy a recordset -
but it's proving to be extremely difficult!!!! What am I doing wrong???



Here's my code:



Dim dbs As Database

Dim rst As Recordset

Dim sql As String



Set dbs = CurrentDb

sql = "SELECT Field1, Field2, Field3 FROM [Table1]" _

& "WHERE ((ID)=[Forms]![MainForm1]![Subform1]![ID])"

Set rst = dbs.OpenRecordset(sql)

sql = "Insert Into Table1 (Field1, Field2, Field3)"

dbs.Execute (sql)



I get a return error message indicating there are too few parameters in "Set
rst = dbs.OpenRecordset(sql)"



Is there a simpler way to capture/copy a Recordset so I can then insert it
into another record?





Any/All help with this will be greatly appreciated!!!



Tom
 
T

Tlm

Excellent! A great help.

Thanks Doug!!!

Tom


Douglas J. Steele said:
Dim dbs As Database
Dim sql As String

Set dbs = CurrentDb

sql = "INSERT INTO Table1 (Field1, Field2, Field3) " & _
"SELECT Field1, Field2, Field3 FROM [Table1] " & _
"WHERE ((ID)=[Forms]![MainForm1]![Subform1]![ID])"

dbs.Execute (sql)




--
Doug Steele, Microsoft Access MVP



Tlm said:
Hello All,



I'm trying to something I thought would be very simple - copy a recordset -
but it's proving to be extremely difficult!!!! What am I doing wrong???



Here's my code:



Dim dbs As Database

Dim rst As Recordset

Dim sql As String



Set dbs = CurrentDb

sql = "SELECT Field1, Field2, Field3 FROM [Table1]" _

& "WHERE ((ID)=[Forms]![MainForm1]![Subform1]![ID])"

Set rst = dbs.OpenRecordset(sql)

sql = "Insert Into Table1 (Field1, Field2, Field3)"

dbs.Execute (sql)



I get a return error message indicating there are too few parameters in "Set
rst = dbs.OpenRecordset(sql)"



Is there a simpler way to capture/copy a Recordset so I can then insert it
into another record?





Any/All help with this will be greatly appreciated!!!



Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top