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

Adding Records From One Table to Another

Status
Not open for further replies.

Muzzy

Programmer
Dec 14, 2001
68
GB
I have two tables, tblCurrentYearExpenditure and tblCurrentYearExpenditureSnap
Once a quarter I need to copy data from tblCurrentYearExpenditure to tblCurrentYearExpenditureSnap. In effect I need to create a snap shot of data in time from tblCurrentYearExpenditure and store it. I will need to add new data to this table as well, i.e. Date snapshot created, with every record added.
The problem being I don't know how to say for every record in tblCurrentYearExpenditure copy to tblCurrentYearExpenditureSnap and add this further information (i.e. Date snapshot created). Please help!
 
Hi

First in tblCurrentYearExpenditureSnap, define each row as the other table, but with an additional column 'datCreated' and set the default value of the column to Date() or Now() depending on how exactly you want the creation date to be held, this way it will automatically populate.

To copy the data use an SQL string like:

INSERT INTO tblCurrentYearExpenditureSnap (field1, field2..etc) SELECT field1, field2,..etc FROM tblCurrentYearExpenditure.

or easier still build an append query in the query builder, save it, and execute that

Regards
Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reaySPAMNOT@talk21.com
remove SPAMNOT to use
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top