Link to home
Start Free TrialLog in
Avatar of ANTHONY CHRISTI
ANTHONY CHRISTIFlag for United States of America

asked on

vba code to copy a table to another table in same DB

Need vba code to copy and replace data in a table called Table1 to a table called Table2 within the same database. Thank you
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<Need vba code to copy and replace data in a table called Table1 to a table called Table2 within the same database.>

Not sure I understand here...?

What does "Copy and replace" mean? ...and how would you both Copy and Replace to another table?

Is your goal here simply to append data from one table to another?

If so then you must provide an example of both tables, (a small sample DB file would be best)  ...then post a clear graphical example of the *exact* result you need.
If you mean copy:

 DoCmd.CopyObject , "Table2", acTable, "Table1"
Are you wanted to update existing records in table2 with data in table1?

Update table1, table2 set table2.somefield = table1.somefield where table1.IDfield = tabl2.idField
Agree with  boag2000, "Copy and Replace" , I overlooked  this requirement.

A sample database with required output clarifies the issue.
Avatar of ANTHONY CHRISTI

ASKER

was exactly what I needed.  Simply.  Thanks.
Thanks for the grade.  Good luck with your project.  -Jim