Hi all,
I am trying to populate a Text Field with a 'yes' or 'no' attribute based on the results of an IF Statement and am running into the Syntax error.
I have a field named 'MAJOR ST' in my street centerline table to create classes for my streets. This is the field I am basing the If statement off of. I have added a field to the table called CAR. This is the field I want to populate with 'yes' or 'no'. If the attribute in the MAJOR_ST field is empty, then CAR should be YES. If the attribute in the MAJOR_ST field is 'Farm', the CAR should be NO. This is the statement I came up with but is causing an Syntax error.
IF ([MAJOR_ST] = "") THEN
[CAR] = "YES"
ELSE IF
([MAJOR_ST] = 'Farm') THEN
[CAR] = "NO"
END IF
Can someone help me with this? All I want to do is populate the CAR field with a Yes or No
Thanks
Solved! Go to Solution.
expression = myExpression
Dim myExpression
([MAJOR_ST] = "Farm") THEN
...
You have to use double quotes
([MAJOR_ST] = "Farm") THEN
Should my Field type for CAR be Text? I tried your suggestion and it still bombed. Also is my Expression field correct?
Thanks
expression = myExpression
Dim myExpression
([MAJOR_ST] = "Farm") THEN
...
That worked!
Thanks.
Change some things on your Field Calculator window.
Expression should be "output"
The Code Block should be
dim output
IF [MAJOR_ST] = "") THEN
output = "YES"
ELSEIF [MAJOR_ST] = "Farm" THEN
output = "NO"
END IF