Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 1st, 2004, 01:38 PM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default UPDATE - SUBQUERY WITH FUNCTION

I need to update an existing record in one table with the result of an aggregation subquery SUM() from another table
This is my attempt which obviously doesn't work with the following error msg: QUERY MUST BE UPDATEABLE

UPDATE ChartofAccounts
   Set ChartofAccounts.[BalCur02] = (SELECT SUM(GeneralLedger.[Value]) FROM GeneralLedger WHERE GeneralLedger.[Period] = 2 AND GeneralLedger.[Account] = '2120')
WHERE C.[Account] = '2120';


Can u help me here?

 
Old November 1st, 2004, 01:49 PM
Authorized User
 
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Crazy-making, isn't it?

You can fool it by using DSum:

UPDATE ChartofAccounts
   Set ChartofAccounts.[BalCur02] = DSUM("[Value]", "GeneralLedger", "[Period] = 2 AND [Account] = '2120'")
WHERE ChartofAccounts.[Account] = '2120';


John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
 
Old November 1st, 2004, 02:10 PM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You are a life-saver - thanks a million mate!!!:D






Similar Threads
Thread Thread Starter Forum Replies Last Post
Subquery debbiecoates SQL Server 2000 4 June 25th, 2008 03:49 AM
Do i have to use a subquery, if yes then how? code_lover SQL Language 2 January 2nd, 2007 02:22 PM
subquery khansa MySQL 1 February 21st, 2006 02:49 AM
Using wildcards in subquery hman SQL Language 2 April 11th, 2005 06:18 AM
SQL SubQuery mcinar SQL Language 2 March 3rd, 2005 12:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.