?
Solved

Update table 1 and get data table 2

Posted on 2012-12-27
5
Medium Priority
?
312 Views
Last Modified: 2012-12-28
Hi Experts,
I am trying to develop a Emp App for a small firm. I am using two table for Loan, detail as follows:

Table 1 Emp_Loan in which loan availed
Table 2 Emp_Loan_Deduction in which monthly loan deduction logged

I need to update table 1 when it is access by user either through report or form. like this, please help to do so.

Update Emp_Loan (Emp_Loan.LDeducted=Sum(Emp_Loan_Deducted .DAmount)
FROM Emp_Loan_Deducted Join Emp_Loan on Emp_Loan_Deducted.EmpID=Emp_Loan.EMPID
Group by Emp_Loan_Deducted.EmpID
HDP.accdb
0
Comment
Question by:Mehram
[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
5 Comments
 
LVL 39

Expert Comment

by:appari
ID: 38723007
try this

Update A
Set LDeducted=DAmount_Sum
FROM Emp_Loan A Join
( Select EmpID, Sum(DAmount) DAmount_Sum From Emp_Loan_Deducted  
Group by Emp_Loan_Deducted.EmpID) B
on A.EmpID=B.EMPID
0
 

Author Comment

by:Mehram
ID: 38723030
Where I need to past it, can you edit please in my mdf
0
 
LVL 17

Expert Comment

by:k_murli_krishna
ID: 38723064
UPDATE Emp_Loan el
SET el.LDeducted = (SELECT SUM(eld.DAmount)
                                FROM Emp_Loan_Deducted eld
                                WHERE eld.EmpID=el.EMPID
                                GROUP BY eld.EmpID);
0
 

Author Comment

by:Mehram
ID: 38723077
Sir, Where I need to past it to work, can you edit please in my mdf
0
 
LVL 77

Accepted Solution

by:
peter57r earned 1500 total points
ID: 38723104
Just based on your posted query, it looks like what you should have is...

Update Emp_Loan  Set LDeducted=DSum("[DAmount]", "[Emp_Loan_Deducted]", "EmpID=" & Emp_Loan.EMPID)

This assumes EMPID is a number field.

The query has no specific reference to any form or report but you can run it anywhere you like.  

You cannot create an update query in Access that has a Group By expression  or any aggregate function Sum/Count/Avg etc; so the previous responses will not work.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

718 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