Solved

Problem with MS Access Update query

Posted on 2006-11-16
5
764 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
ID: 17956892
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
ID: 17956947
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
ID: 17957387

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
ID: 17961143
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
ID: 17963332
Thanks
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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 the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

863 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

20 Experts available now in Live!

Get 1:1 Help Now