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

How do Insert into a table

Status
Not open for further replies.

bryant89

Programmer
Nov 23, 2000
150
CA
To keep it kind of simple in my explanation...

I need to be able to be able to insert multiple records into a table from a button click event. I want to set up a loop in the code for the button click event that will loop through one table retrieving records while inserting into a different table

Note: I have already got the procedure to retrieve records that I want using a recordset called rs_sp. Now I want to take these records and insert them into a different table in my current database at the same time I am looping through the rs_sp recordset.


If anyone has an example they could post or point me to that would be great. I have been looking in the help and trying different things but I cant seem to find exactly how to do it.

I hope this all makes sense.
Any help would be greatly appreciated

Bryant
 
why not just use an append Query ?

or just open a second recordset

dim rst1 as recordset,rst2 as recordset
dim db as database
set db = currentdb
set rst1 = db.openrecordset(tablegetfromname)
set rst2 = db.openrecoreset(tableappendtoname)
rst1.movefirst
do until rst1.EOF
rst2.addnew
rst2!fieldname = rst1!fieldname
'Add like above line for each field
rst2.update
loop
rst1.close
rst2.close
 
Thank you very much for the help... That is exactly what I needed to do. I am just a junior programmer so I thank you very much for your detail.
Bryant Moore
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top