Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access 2010 - copy from one table to another

Posted on 2014-03-22
4
Medium Priority
?
4,225 Views
Last Modified: 2014-03-22
When I change a value in table 1 I want to automatically copy the changed record to a new line in table 2.

How is this done?

Thx in advance.

Regards
Lars
0
Comment
Question by:LarsDyrby
[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
  • 2
4 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 39947293
2010 includes the new Data Macro that can help to do this, but if you're always doing this through a Form, then you could use straight SQL and VBA.

In the Form's BeforeUpdate event, do this:

Currentdb.Execute "INSERT INTO YourTable (Col1, Col2, Col3) VALUES(" & Me.tx1 & "," & Me.tx2 & "," & Me.tx3 & ")"

If any of those are Text fields, you'll have to surround them with single or double quotes as I did below for tx1. It here are any Date fields, you'd use the hash mark (#), as I did below for tx3:

Currentdb.Execute "INSERT INTO YourTable (Col1, Col2, Col3) VALUES('" & Me.tx1 & "'," & Me.tx2 & ",#" & Me.tx3 & "#)"

If you'd prefer to use Data Macros, see this article:

http://www.databasejournal.com/features/msaccess/article.php/3905921/Leveraging-Data-Macro-in-Microsoft-Access-2010.htm
0
 

Author Closing Comment

by:LarsDyrby
ID: 39947372
I used the solution in the Data Macro link in the bottom of the answer.
Worked beautifully.

Thx Scott

Regards
Lars
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 39947373
Just a side question here, why?

Unless the 2nd table is some form of audit trail, I question the necessity (or the logic in) of storing duplicate information in multiple tables.
0
 

Author Comment

by:LarsDyrby
ID: 39947751
...which exactly is the purpose of table 2.

Regards
Lars
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

721 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