Need help on update query, please

bravura

Board Regular
Joined
Jan 27, 2010
Messages
51
I set it up like this but it's updating every line in my table, not just those lines that meet field criteria.

Update tbl_A Set tbl_A.USFLAG = -1 (true)
Where ((tbl_A.Field1 = "X" or "Y" or "Z") OR (tbl_A.Field2 = "X" or "Y" or "Z") etc. etc. etc. )) ;

///

Want to update USFLAG field to TRUE (-1) if Field1 = Alpha, Bravo or Charlie, or if Field2 = Alpha, Bravo or Charlie, etc.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
You need to repeat your test using the field name each time.
Code:
tbl_A.Field1 = "X" or tbl_A.Field1 = "Y"

Perhaps consider using IN() instead?

You can always test your logic in the Immediate Window? Try setting a variable, then print the result of your comparison, and see what you get.
 
Upvote 0

Forum statistics

Threads
1,216,084
Messages
6,128,726
Members
449,465
Latest member
TAKLAM

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top