Solved

Access update one tbl with contents from anohter tbl

Posted on 2014-02-28
6
269 Views
Last Modified: 2014-02-28
I have a table called "Source". The source table has three fields called A, B, and C. Fields A and B are primary keys. Field C has amounts that I want to copy to my "target" table based on matching the two primary keys. The target table also has fields A, B, and C. How do I do this?
conernesto
0
Comment
Question by:Conernesto
  • 3
  • 3
6 Comments
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
Try running an update query:

UPDATE Source, Target
SET Target.c = Source.c
WHERE Source.a = Target.a AND source.B = Target.b

Open in new window

0
 

Author Comment

by:Conernesto
Comment Utility
I am not sure how to do this.
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
1.  Open a new query
2.  Close the "Show Table" dialog without selecting any tables.
3.  Right click the query window and select "SQL View"
4.  Copy/paste the SQL I gave you into the SQL Window
5.  Try running it by clicking the Exclamation Point above the query window OR by right-clicking the query window and selecting Datasheet View.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:Conernesto
Comment Utility
It worked. How can I put the above code in a command button?
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
Comment Utility
You can embed it in VBA in the click event of your command button like this:

Sub YourCommandButtonName_Click()
       Dim strSQL as string
       strSQL = "UPDATE Source, Target SET Target.c = Source.c WHERE Source.a = Target.a AND source.B = Target.b"
      CurrentDB.Execute strSQL, dbFailOnError
End Sub

Open in new window

0
 

Author Closing Comment

by:Conernesto
Comment Utility
Thank you.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now