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

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
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,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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