Update Query with a join to another query - Help

ry94080

New member
Local time
Yesterday, 16:38
Joined
Apr 19, 2018
Messages
3
Hello,

I'm trying to create an update query that contains a join to another query. Usually you get the error, "Operation must use an updateable query."

i'm trying to avoid creating a temporary table that contains the contents of the query.

I have the query below, but it is not working as expected:

Code:
DoCmd.RunSQL "UPDATE tblPharmacyCultures SET tblPharmacyCultures.[Finaled] = True WHERE EXISTS(Select * from vPharmacyAccNo_Finaled WHERE vPharmacyAccNo_Finaled.Accession = tblPharmacyCultures.Accession)"

Any ideas appreciated
 
maybe:
Code:
DoCmd.RunSQL "UPDATE tblPharmacyCultures 
SET tblPharmacyCultures.[Finaled] = True 
WHERE Exists (SELECT NULL FROM vPharmacyAccNo_Finaled WHERE Accession = tblPharmacyCultures.Accession);"
 
maybe:
Code:
DoCmd.RunSQL "UPDATE tblPharmacyCultures
SET tblPharmacyCultures.[Finaled] = True
WHERE Exists (SELECT NULL FROM vPharmacyAccNo_Finaled WHERE Accession = tblPharmacyCultures.Accession);"
I tried that, but it updates every single record. Which should be the case. It should only update the records that have matching accessions from the vPharmacyAccNo_Finaled query.
 
try this:
Code:
DoCmd.RunSQL "UPDATE tblPharmacyCultures 
  SET tblPharmacyCultures.[Finaled] = True 
WHERE Accession In (SELECT Accession From vPharmacyAccNo_Finaled)"
 
Sounds like a schema design problem. Perhaps the field you are trying to update belongs in a different table.
 

Users who are viewing this thread

Back
Top Bottom