How do I inject/dump the data from a recordset into an existing table via VBA?

Chatbox

Registered User.
Local time
Today, 16:49
Joined
Aug 30, 2004
Messages
68
Say I have a table [tbl1] and a recordset [rst1].
The fields in both items are the same. Now, how do I copy/dump/inject (what's the correct term?) the data from the recordset into the table?
 
Chatbox,

Didn't the data in the recordset come from the table?

Wayne
 
Append or Insert is the correct term. Rather than making a recordset, you can just run a query that selects data from the recordset's source and appends it to whatever table you choose. Since all the column names are the same, Access will automatically populate the Append To cells:

1. Create a new query.
2. Select the table or query that contains the records you want.
3. Select the columns you want from the source table.
4. Change the query type to Append. (query on the menu bar, then append)
5. If all the Append To cells populated for all the selected, you're done. If any are empty, you'll need to select the target field manually.
6. Save the query.

If you actually need to do this with a recordset (the query is more efficient and certainly easier to "code"), then you'll need to write either DAO or ADO code to add the recordset records to a table. Search help for .AddNew to find sample code.
 

Users who are viewing this thread

Back
Top Bottom