Thanks, but unfortunately you haven’t hit the point: [ME DATE] is a table.
Well, let me better explain all this mess...
The table DSPC_PATIENT should store information about dates on which
patients respond to medical treatment.
Those dates are not stored in any of the tables of the database. You have to
calculate them through a query. Here it is:
SELECT ID, MIN(CDATE)
FROM [DM_TOTHAM17 AT ALL VISITS]
WHERE TOTHAM_17ITEMS<=50*(SELECT TOTHAM17 FROM [DM_HAM AT BAS] WHERE [DM_HAM
AT BAS].ID= [DM_TOTHAM17 AT ALL VISITS].ID)\100
GROUP BY ID;
This query works fine: I have tested it.
Since this query will use aggregate function, it cannot be used as subquery
in the update statement or I get the awful message you know.
So I moved around by creating a table - the [ME DATE] - from the query:
SELECT ID, MIN(CDATE) INTO [ME DATE]
FROM [DM_TOTHAM17 AT ALL VISITS]
WHERE TOTHAM_17ITEMS<=50*(SELECT TOTHAM17 FROM [DM_HAM AT BAS] WHERE [DM_HAM
AT BAS].ID= [DM_TOTHAM17 AT ALL VISITS].ID)\100
GROUP BY ID;
This table will have one record for each patient. And I’m using this table
in my update statement. No aggregate function at all…. although JET is so
smart to *understand* that this table comes from something which will use
one. And I really don’t think it can happen…
Hope things are clearer know.
Pat Hartman(MVP) said:
Sounds like [Me DATES] is a query that uses aggregate functions. Even
though Jet could technically perform the requested update, it won't do it if
ANY part of the query is not updatable.
Looks like you are trying to capture some piece of information from a
many-side table so you can store it in a one-side table. This is not
advised. Every time the many-side table changes, you would have to be sure
to update the one-side table or the data in the one-side table would be
invalid. It is good practice to always use a query to obtain this data
rather than duplicating it.
rocco said:
Hello,
few days ago I have posted a message with the same subject. My code was a
bit different from this one and the answer was that I received the err
message "Operation must use an updatable query" because I was using
aggregate
function in my subqueries.
I have changed the design of the main query and the code is now:
UPDATE DSPC_PATIENT
SET BLDATE=(SELECT BLDATE FROM [ME DATES] WHERE [ME DATES].ID=1)
WHERE DSPC_PATIENT.ID=1
well... I still receive the err message!!!!!!!!!!! Why?
In [ME DATES] there is one and only one record for any ID.
Thanks,
Rocco