update query with subqueries, not updateable (1 Viewer)

Domski74

Registered User.
Local time
Today, 03:16
Joined
Jan 29, 2009
Messages
18
Hi All

I'm trying to set a day count based on the number of days in the year and take account of possible leap years. The table only ever contains a years cumulative data and the day count needs to run from the first of April and be flexiable enough not to need maintenance to account for a new year. I've witten the below which works fine in a select query butI get a not updateable error in the update?

Code:
UPDATE Pharmacy SET Pharmacy.MRN = "UK" & (DateSerial((select year(min([RIODate])) from Pharmacy)+1,3,31)-DateSerial((select year(min([RIODate])) from Pharmacy),4,1))-(DateSerial((select year(min([RIODate])) from Pharmacy)+1,3,31)-[RIODate])+1;

Please can anyone advise how to correct this so it will work?

Many thanks

Dominic
 

khawar

AWF VIP
Local time
Today, 06:16
Joined
Oct 28, 2006
Messages
870
Make a temporary table from selected data and then main table with data from that temporary table
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 22:16
Joined
Feb 19, 2002
Messages
43,346
Queries that aggregate data are not updateable. Period.

I think your query should be updateable since the column being updated is explicitly identifiable. It is only the value that is "aggregated". But the Jet/ACE developers don't see it my way.
 

Users who are viewing this thread

Top Bottom