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
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
  • 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)
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access Report formatting issue 5 72
Access vs Access runtime 6 63
Fields don't match on a query 9 43
usage of ms/excell 3d maps in ms/access 2016 6 42
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

732 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