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

Copy recordset into table

Status
Not open for further replies.

jsnels

Programmer
Jan 25, 2002
1
NL
What's the best way to copy an in memory recordset to an access table if they have the same structure. I know this can be done row by row, but is there a better way. All data in the access tables should be discarded. So after the operation the recordset and table are equal.

 
let us say that you recordset is
Code:
Select custid,sum(orderamount) as thismonthorders,month(orderdate)thismonth,year(orderdate)thisyear
from orders
where month(orderdate)= month(date()) and year(orderdate)= year(date()))
group by custid,thismonthorders,thismonth,thisyear

run this code
Code:
currentdb.execute
insert into tablename(custid,thismonthorders,thismonth,thisyear)Select custid,sum(orderamount) as thismonthorders,month(orderdate)thismonth,year(orderdate)thisyear
from orders
where month(orderdate)= month(date()) and year(orderdate)= year(date()))
group by custid,thismonthorders,thismonth,thisyear
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top