Microsoft
Software
Hardware
Network
Question : Problem with MS Access Update query
I am trying to create a query in MS Access that will update my PAYSHEET table with data from a table called
"CallCenterPaymentPendingU
pdate_Pays
heet_Sourc
e#". Both tables have a multiple column PK set consisting of paysheet.techID & Paysheet.Region & Paysheet.PaysheetTypeNumbe
r & 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.PaysheetTypeNumbe
r & 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]+[CallC
enterPayme
ntPendingU
pdate_Pays
heet_Sourc
e#].[NumPa
yments]
WHERE
cstr(paysheet.techID & Paysheet.Region & Paysheet.PaysheetTypeNumbe
r & Paysheet.ReportDate & Paysheet.ItemNumber)
in
(
SELECT cstr(paysheet.techID & Paysheet.Region & Paysheet.PaysheetTypeNumbe
r & Paysheet.ReportDate & Paysheet.ItemNumber)
FROM
paysheet INNER JOIN [CallCenterPaymentPendingU
pdate_Pays
heet_Sourc
e#] ON [CallCenterPaymentPendingU
pdate_Pays
heet_Sourc
e#].TechID
=
Paysheet.TechID
AND [CallCenterPaymentPendingU
pdate_Pays
heet_Sourc
e#].Region
= Paysheet.Region
AND [CallCenterPaymentPendingU
pdate_Pays
heet_Sourc
e#].Payshe
etTypeNumb
er = Paysheet.PaysheetTypeNumbe
r
AND [CallCenterPaymentPendingU
pdate_Pays
heet_Sourc
e#].Report
Date = Paysheet.ReportDate
AND [CallCenterPaymentPendingU
pdate_Pays
heet_Sourc
e#].ItemNu
mber = Paysheet.ItemNumber)
Which gives me an prompt box because it does not know what [CallCenterPaymentPendingU
pdate_Pays
heet_Sourc
e#].[NumPa
yments] is.
So I tried this query:
UPDATE Paysheet INNER JOIN [CallCenterPaymentPendingU
pdate_Pays
heet_Sourc
e#] ON (Paysheet.Region =
[CallCenterPaymentPendingU
pdate_Pays
heet_Sourc
e#].Region
) AND (Paysheet.PaysheetTypeNumb
er =
[CallCenterPaymentPendingU
pdate_Pays
heet_Sourc
e#].Payshe
etTypeNumb
er) AND (Paysheet.TechID =
[CallCenterPaymentPendingU
pdate_Pays
heet_Sourc
e#].TechID
) AND (Paysheet.ReportDate =
[CallCenterPaymentPendingU
pdate_Pays
heet_Sourc
e#].Report
Date) AND (Paysheet.ItemNumber =
[CallCenterPaymentPendingU
pdate_Pays
heet_Sourc
e#].ItemNu
mber) SET Paysheet.Amount =
[paysheet].[Amount]+DLookU
p("NumPaym
ents","Cal
lCenterPay
mentPendin
gUpdate_Pa
ysheet_Sou
rce#","Reg
ion = " & Paysheet.Region & " AND
techID = " & Paysheet.techID & " AND PaysheetTypeNumber = " & Paysheet.PaysheetTypeNumbe
r & " AND ReportDate = " &
Paysheet.ReportDate & " AND ItemNumber = " & Paysheet.ItemNumber);
But I get the error "Operation must use an updatable query" again.
Help!
Answer : Problem with MS Access Update query
Have the data you want to update in a stand alone table, this should fix the error.
Carl.
Random Solutions
Disabling Only Checkboxes in Checkboxlist Control
Using a geometry type check constrint in sql sever 2008
Display image
Microsoft, Access, 2007, Call sub without return
Subtotaling Group Calculated Fields
SQL Server Authentication
Loop through each table, then Find & Replace
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
Hibernate Exception - Errors in named queries
Resubmitting with correct file attached!: How to Hyperlink Column of UPS Tracking Numbers in Excel to UPS Webpage