views:

60

answers:

2

Trying to get this query to work in MS Access.

Update Network.Location=Enclave.Location Where Enclave.Site=No AND 
Network.AlternateLocation=Enclave.Location Where Enclave.Site=Yes

I'm not sure how to get this to do exactly what I want which is store Enclave location in network location if the enclave site field is No and if yes store encalve location in alternate location, meaning it would store a blank value in network location in that row.

Key fields update:

Update Network InnerJoin Enclave On Network.ID=Enclave.ID Set 
Network.Location=Enclave.Location Where Enclave.Site=No AND 
Network.AlternateLocation=Enclave.Location Where Enclave.Site=Yes
+2  A: 

You should break the command in two:

Update Network SET Location=Enclave.Location Where Enclave.Site=No;
Update Network SET AlternateLocation=Enclave.Location Where Enclave.Site=Yes;
pcent
Can you provide some more details about the tables involved?I've just realized there are two of them
pcent
and it seems as if I can't have two update statements in one update query in access. because when I try to close the query i get an error at the second update
Jake
I'd like to know the key fields to join the tables:UPDATE Network n SET Location = e.location from enclave e where n.id = e.id and e.Site = NO
pcent
I'm not access expert, but can't you create two query objects instead of one?
pcent
No you can join queries that return records, but you can only have one update clause in access. so having two separate update clauses will not work unless I have two different query files which I don't want to do
Jake
+1  A: 
UPDATE Network Inner Join Enclave ON Network.ID=Enclave.ID
SET Network.Location = IIF(Enclave.Site=False, Enclave.Location, ""),
Network.AlternateLocation = IIF(Enclave.Site=True, Enclave.Location, "")

Note: I haven't tried this & guess, this should work.
Also, I have assumed that you will want the field to be updated with blank, if it doesn't satisfy the condition.

shahkalpesh
you are the man..I knew it was something like this just couldn't find out the if conition syntax
Jake