question about update query

M

mcnews

why does query 2 error out with must be upadatable query?

query 1

SELECT tblCDC.ID, Count(tblCDC.result1) AS CountOfresult1
FROM tblCDC
GROUP BY tblCDC.ID
HAVING (((Count(tblCDC.result1))=1));

query 2

UPDATE tblCompare INNER JOIN qrySum1 ON tblCompare.ID=qrySum1.ID SET
tblCompare.combined = [countofresult1];



tia,
mcnewsxp
 
J

John Spencer

Because any UPDATE query that has a aggregate query in it (other than in a
where clause) is automatically deemed as not updatable by Access.
Logically, I don't think that makes sense, but ...

Workarounds are to pump the data in query 1 into a table and then use that
table in your update OR use the VBA Domain functions.

UPDATE tblCompare
SET tblCompare.Combined = DCount("Result1","tblCDC","ID=" & tblCompare.ID)

IF the field ID is not numeric, then you need to include quote mark
delimiters, as below

UPDATE tblCompare
SET tblCompare.Combined = DCount("Result1","tblCDC","ID=""" & tblCompare.ID
& """")
 
M

mcnews

John said:
Because any UPDATE query that has a aggregate query in it (other than in a
where clause) is automatically deemed as not updatable by Access.
Logically, I don't think that makes sense, but ...

Workarounds are to pump the data in query 1 into a table and then use that
table in your update OR use the VBA Domain functions.

UPDATE tblCompare
SET tblCompare.Combined = DCount("Result1","tblCDC","ID=" & tblCompare.ID)

IF the field ID is not numeric, then you need to include quote mark
delimiters, as below

UPDATE tblCompare
SET tblCompare.Combined = DCount("Result1","tblCDC","ID=""" & tblCompare.ID
& """")

sweet!
thanks much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top