A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Update table from Result of Query



 
 
Thread Tools Display Modes
  #1  
Old September 29th, 2004, 02:17 AM
JoeCL
external usenet poster
 
Posts: n/a
Default Update table from Result of Query

Hello!

I wanted to update a field of a table from the result of a
query. How should I do this? I tried putting the Select
statement of the query to the criteria of the update query
but I am getting the error 'Operation must use an
updateable query' Thanks.

  #2  
Old September 29th, 2004, 04:17 AM
Duane Hookom
external usenet poster
 
Posts: n/a
Default

Replace the "result of a query" with a domain aggregate function such as
DLookup() or DSum().

--
Duane Hookom
MS Access MVP


"JoeCL" wrote in message
...
Hello!

I wanted to update a field of a table from the result of a
query. How should I do this? I tried putting the Select
statement of the query to the criteria of the update query
but I am getting the error 'Operation must use an
updateable query' Thanks.



  #3  
Old September 29th, 2004, 06:58 AM
John Vinson
external usenet poster
 
Posts: n/a
Default

On Tue, 28 Sep 2004 18:17:28 -0700, "JoeCL"
wrote:

Hello!

I wanted to update a field of a table from the result of a
query. How should I do this? I tried putting the Select
statement of the query to the criteria of the update query
but I am getting the error 'Operation must use an
updateable query' Thanks.


Not all queries are updateable; any Query that has any totals
operation (Sum, Count, etc.) is not, for instance. Some table join
queries are updateable, some aren't.

Please open the query in SQL view and post it here. Someone should be
able to suggest a fix or a getaround.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
  #4  
Old September 30th, 2004, 07:29 PM
external usenet poster
 
Posts: n/a
Default

John,

Here's the SQL View.

UPDATE [Counter] SET [Counter].N01 = (SELECT Count(*)
FROM Survey1 WHERE 1 In (First,Second,Third,Fourth,Fifth));

The table Counter is the only table in the query window.

Thanks.

Joe

-----Original Message-----
On Tue, 28 Sep 2004 18:17:28 -0700, "JoeCL"
wrote:

Hello!

I wanted to update a field of a table from the result of

a
query. How should I do this? I tried putting the Select
statement of the query to the criteria of the update

query
but I am getting the error 'Operation must use an
updateable query' Thanks.


Not all queries are updateable; any Query that has any

totals
operation (Sum, Count, etc.) is not, for instance. Some

table join
queries are updateable, some aren't.

Please open the query in SQL view and post it here.

Someone should be
able to suggest a fix or a getaround.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
.

  #5  
Old October 1st, 2004, 09:14 PM
John Vinson
external usenet poster
 
Posts: n/a
Default

On Tue, 28 Sep 2004 18:17:28 -0700, "JoeCL"
wrote:

Hello!

I wanted to update a field of a table from the result of a
query. How should I do this? I tried putting the Select
statement of the query to the criteria of the update query
but I am getting the error 'Operation must use an
updateable query' Thanks.


Joe, my ISP has for some reason locked your reply to my answer so I
can't download it. Please pardon the inconvenience and repost it for
me.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
  #6  
Old October 4th, 2004, 12:30 AM
John Vinson
external usenet poster
 
Posts: n/a
Default

On Tue, 28 Sep 2004 18:17:28 -0700, "JoeCL"
wrote:

Hello!

I wanted to update a field of a table from the result of a
query. How should I do this? I tried putting the Select
statement of the query to the criteria of the update query
but I am getting the error 'Operation must use an
updateable query' Thanks.


I had to go to Google Groups to find your reply:

John,

Here's the SQL View.

UPDATE [Counter] SET [Counter].N01 = (SELECT Count(*)
FROM Survey1 WHERE 1 In (First,Second,Third,Fourth,Fifth));

The table Counter is the only table in the query window.

Thanks.

Joe


The problem is that ANY query containing a Count operation is ipso
facto not updateable, even in cases (such as this) where it would be
logically reasonable.

The solution is to use the DCount() domain function to get the count -
IF you want to do this at all. I'm VERY queasy about a table design
with fields named First, Second, Third, Fourth and Fifth; and even
queasier about storing a derived-data value such as a count in a table
at all.

The short answer:

UPDATE [counter] SET [Counter].[No1] = DCount("*", "[Survey1]",
"[First] = 1 OR [Second] = 1 OR [Third] = 1 OR [Fourth] = 1 OR [Fifth]
= 1")

The better answer: Reconsider your table structure, and/or post a
description of that structure and explain what you're trying to
accomplish!

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Update two subforms based on one table together? Flora Using Forms 0 August 6th, 2004 12:59 AM
Delete Query based on result of select query John Finch Running & Setting Up Queries 1 July 2nd, 2004 05:47 PM
Using an update query to load one table from another gglazer Running & Setting Up Queries 2 June 23rd, 2004 07:02 PM
COMPARE THE TWO TABLES Stefanie General Discussion 0 June 4th, 2004 04:36 PM
HELP: Update 1 table with calculated fields from another table Samora Running & Setting Up Queries 0 May 23rd, 2004 05:16 PM


All times are GMT +1. The time now is 05:13 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.