update with iif function in access

learning_grexcel

Active Member
Joined
Jan 29, 2011
Messages
319
i tried to update a field in a table with the following code but it doesn't work

update table set system = iif(name='tim*', xyzsystem, "othersystem")

if in name field value starts with tim*, it should put xyzsystem, otherwise othersystem
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Try you can't use = when using wildcards, it will look for an exact match.

So the condition name = 'tim*' is looking for the string 'tim*' not beginning with 'tim'.

You could try this.
Code:
update table set system = iif(name Like "tim*", xyzsystem, "othersystem")
Or this.
Code:
update table set system = iif(InStr(name,"tim*")>0 , xyzsystem, "othersystem")
 
Upvote 0
thanks mate
can I use OR statement like below?
Code:
update table set system = iif(name like "tim*" or "rim*", xyzsystem, "othersystem")
 
Upvote 0

Forum statistics

Threads
1,224,812
Messages
6,181,104
Members
453,021
Latest member
Justyna P

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