UPDATE statement with subquery

Posted on 2008-10-28
Last Modified: 2010-08-05
I have the following query and when I try to execute it I get a message of You have written a subquery that can return more than one field without using the EXISTS reserved work in the main querys from clause.   I'm using Microsoft Access and am not sure how to revise the query.  Any help would be greatly appreciated.  I'm using Microsoft Access 2003.


update caserecords b
set unithours  = (select caseid, sum(casehours) as hours, int(sum(casehours)/60)&":"& (sum(casehours) mod 60)   as total_time from contactevents a
where = a.caseid
group by caseid)

Open in new window

Question by:lfolku
  • 4
  • 2
LVL 11

Expert Comment

ID: 22825341
You have set unithours  = followed by several fields.  Access thinks you are trying to assign multiple values to the unnithours field.
LVL 11

Expert Comment

ID: 22825390
I think you meant to do something like this:

UPDATE caserecords AS b LEFT JOIN contactevents AS a USING
SET b.unithours = int(sum(a.casehours)/60)&":"& (sum(a.casehours) mod 60)

This is very complex though, you might want to try setting a simpler value to make sure the other syntax is correct first.
LVL 11

Accepted Solution

miqrogroove earned 250 total points
ID: 22825402
Oops the USING term is not correct..

UPDATE caserecords AS b LEFT JOIN contactevents AS a ON
SET b.unithours = int(sum(a.casehours)/60)&":"& (sum(a.casehours) mod 60)
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.


Author Comment

ID: 22825480

I get a syntax error (missing operator) in query expression  'int(sum(a.casehours)/60)&":"& (sum(a.casehours) mod 60)

LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 250 total points
ID: 22825959
what about thius:
LVL 11

Expert Comment

ID: 22826197
I can't get Jet to eat a multi-table update command.  Try angellll's idea, and if that doesn't work we can write a query loop.

Author Closing Comment

ID: 31515918
Thanks for your help.

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 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