Re: update query
From: John Vinson (jvinson_at_STOP_SPAM.WysardOfInfo.com)
Date: 08/02/04
- Next message: John Vinson: "Re: Setting Values to Null or False Using a Update Query"
- Previous message: Tom Ellison: "Re: Parameter Query"
- In reply to: Ivan Debono: "update query"
- Next in thread: Ivan Debono: "Re: update query"
- Reply: Ivan Debono: "Re: update query"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 02 Aug 2004 13:22:09 -0600
On Mon, 2 Aug 2004 08:26:16 +0200, "Ivan Debono"
<ivanmdeb@hotmail.com> wrote:
>I have the following query:
>
>UPDATE plans SET plan_date = (
>SELECT Min(calendar.date)
>FROM calendar
>WHERE (((calendar.completed_yn)=False) AND ((calendar.deleted_yn)=False) AND
>((calendar.parent_table)='plans') AND ((calendar.parent_id)=64))
>)
>WHERE plans.id = 64
>
>What is does is that it updates the plan_date in table plans with the
>smallest date in table calendar which is not deleted and not completed.
>
>But I get an error: Operation must use an updatable query. (Error 3073)
>
>Anyone knows why??
Because any query that contains a Min, Max, or any other Totals
operation is non-updateable... even if (as in this case) it is not a
logical constraint! It's just the way Access was implemented.
You can use the DMin() VBA function in place of the subquery:
UPDATE plans
SET plan_date = DMin("[Date]", "[calendar]", "[Completed_yn] = False
AND deleted_yn = False AND parent_table = 'Plans' and parent_id = " &
[Plans.ID])
WHERE plans.ID = <criteria>
Note that I'm suggesting using a "correlated" pseudo-subquery,
referencing the outer query's ID rather than explicitly putting 64
into both the main query criterion and the DMin().
John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
- Next message: John Vinson: "Re: Setting Values to Null or False Using a Update Query"
- Previous message: Tom Ellison: "Re: Parameter Query"
- In reply to: Ivan Debono: "update query"
- Next in thread: Ivan Debono: "Re: update query"
- Reply: Ivan Debono: "Re: update query"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|