Updating multiple fields in a table

Leathem

Registered User.
Local time
Today, 01:37
Joined
Nov 29, 2010
Messages
58
I am trying to use an update query to update several fields in a table. The following code works fine for one field:

UPDATE [Trip Registration]
SET [Trip Registration].[Trip1 Confirm] = "C" WHERE (([Trip Registration].[Trip1 Coord])=True);

but the problem is that I'd also like the same query to update two other fields (Trip2 Confirm and Trip3 Confirm) using the same kind of criteria. That is, if Trip2 Coord is True, set Trip 2 Confirm to "C", and the same for Trip3. I don't know how to set up the query to do the independent checks and updates in one step.
 
How about something like...
After copying your table to a backup table....
Try opening a new query and pasting this into your sql view.

UPDATE [Trip Registration]
SET [Trip Registration].[Trip1 Confirm] = IIF([Trip Registration].[Trip1 Coord]=True,"C",""),
[Trip Registration].[Trip2 Confirm] = IIF([Trip Registration].[Trip2 Coord]=True,"C",""),
[Trip Registration].[Trip3 Confirm] = IIF([Trip Registration].[Trip3 Coord]=True,"C","")

WHERE [Trip Registration].[Trip1 Coord]=True
OR [Trip Registration].[Trip2 Coord])=True
OR [Trip Registration].[Trip3 Coord])=True
 
Thanks, Bob. It worked fine!
 

Users who are viewing this thread

Back
Top Bottom