Solved

Problem with MS Access Update query

Posted on 2006-11-16
5
763 Views
Last Modified: 2008-01-09
I am trying to create a query in MS Access that will update my PAYSHEET table with data from a table called
"CallCenterPaymentPendingUpdate_Paysheet_Source#".  Both tables have a multiple column PK set consisting of paysheet.techID & Paysheet.Region & Paysheet.PaysheetTypeNumber &  Paysheet.ReportDate & Paysheet.ItemNumber.

I know that the "HAVING IN SELECT" or "WHERE IN SELECT" typically users just one field to match on, but I need to link them on the combined PK  so I concatinated the fileds like so:  paysheet.techID & Paysheet.Region & Paysheet.PaysheetTypeNumber &  Paysheet.ReportDate & Paysheet.ItemNumber.

Because I need to link two tables I keep getting the error "Operation must use an updatable query".  SO I rewrite it using a correlated subquery.  The closest I can get to solving this problem is this query:

UPDATE Paysheet
SET Amount = [paysheet].[Amount]+[CallCenterPaymentPendingUpdate_Paysheet_Source#].[NumPayments]
WHERE
cstr(paysheet.techID & Paysheet.Region & Paysheet.PaysheetTypeNumber &  Paysheet.ReportDate & Paysheet.ItemNumber)
in
(
SELECT cstr(paysheet.techID & Paysheet.Region & Paysheet.PaysheetTypeNumber &  Paysheet.ReportDate & Paysheet.ItemNumber)
FROM
paysheet INNER JOIN  [CallCenterPaymentPendingUpdate_Paysheet_Source#]  ON [CallCenterPaymentPendingUpdate_Paysheet_Source#].TechID =
Paysheet.TechID
AND   [CallCenterPaymentPendingUpdate_Paysheet_Source#].Region = Paysheet.Region
AND   [CallCenterPaymentPendingUpdate_Paysheet_Source#].PaysheetTypeNumber = Paysheet.PaysheetTypeNumber
AND   [CallCenterPaymentPendingUpdate_Paysheet_Source#].ReportDate = Paysheet.ReportDate
AND   [CallCenterPaymentPendingUpdate_Paysheet_Source#].ItemNumber = Paysheet.ItemNumber)

Which gives me an prompt box because it does not know what [CallCenterPaymentPendingUpdate_Paysheet_Source#].[NumPayments] is.

So I tried this query:

UPDATE Paysheet INNER JOIN [CallCenterPaymentPendingUpdate_Paysheet_Source#] ON (Paysheet.Region =
[CallCenterPaymentPendingUpdate_Paysheet_Source#].Region) AND (Paysheet.PaysheetTypeNumber =
[CallCenterPaymentPendingUpdate_Paysheet_Source#].PaysheetTypeNumber) AND (Paysheet.TechID =
[CallCenterPaymentPendingUpdate_Paysheet_Source#].TechID) AND (Paysheet.ReportDate =
[CallCenterPaymentPendingUpdate_Paysheet_Source#].ReportDate) AND (Paysheet.ItemNumber =
[CallCenterPaymentPendingUpdate_Paysheet_Source#].ItemNumber) SET Paysheet.Amount =
[paysheet].[Amount]+DLookUp("NumPayments","CallCenterPaymentPendingUpdate_Paysheet_Source#","Region = " & Paysheet.Region & " AND
techID = " & Paysheet.techID & "  AND PaysheetTypeNumber = " & Paysheet.PaysheetTypeNumber & " AND ReportDate = " &
Paysheet.ReportDate & " AND ItemNumber = " & Paysheet.ItemNumber);

But I get the error "Operation must use an updatable query" again.

Help!
0
Comment
Question by:cef_soothsayer
  • 3
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
Carl2002 earned 500 total points
Comment Utility
Have the data you want to update in a stand alone table, this should fix the error.

Carl.
0
 
LVL 1

Author Comment

by:cef_soothsayer
Comment Utility
Carl,  Please explain further...

The purpose here is to update the PAYMENTS table with data from a newly imported table.
This will be done daily so as to keep the payemnts table up to date with each new import.
I do not have the option of altering the PK on the payments table either.
0
 
LVL 1

Author Comment

by:cef_soothsayer
Comment Utility

I think I just fixed this...

CallCenterPaymentPendingUpdate_Paysheet_Source# is not really a table - it is a query.  And it contains a count aggregate which is by definition not updatable in access, even if the aggregate is used in a subquery.



0
 
LVL 1

Author Comment

by:cef_soothsayer
Comment Utility
Since Carl's comment led me to think in the right direction I'll award him the points...
0
 
LVL 4

Expert Comment

by:Carl2002
Comment Utility
Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

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

12 Experts available now in Live!

Get 1:1 Help Now