[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2013-01-02
7
Medium Priority
?
420 Views
Last Modified: 2013-01-07
Need vba code to copy and replace data in a table called Table1 to a table called Table2 within the same database. Thank you
0
Comment
Question by:Startrac98
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 38738016
>Need vba code to copy and replace data
Assuming this means replace all of Table1 records with Table2 records, that's Two queries:

DELETE * FROM Table1

INSERT INTO Table1 SELECT * FROM Table2

This assumes that the design of Table1 and Table2 are an exact match.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38738056
<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.
0
 
LVL 31

Expert Comment

by:hnasr
ID: 38738086
If you mean copy:

 DoCmd.CopyObject , "Table2", acTable, "Table1"
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 26

Expert Comment

by:jerryb30
ID: 38738155
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
0
 
LVL 31

Expert Comment

by:hnasr
ID: 38738341
Agree with  boag2000, "Copy and Replace" , I overlooked  this requirement.

A sample database with required output clarifies the issue.
0
 

Author Closing Comment

by:Startrac98
ID: 38750778
was exactly what I needed.  Simply.  Thanks.
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 38750792
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question