Copy a Recordset???

  • Thread starter Thread starter Tlm
  • Start date Start date
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
 
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
 
Back
Top