Without seeing the code, I can only guess...but I'll share what I've learned about If...then...else statements in calculate field...it's all in how you structure the line breaks.
Example 1:
dim result as string
if [location] = â?�HOMEâ?� then result = â?�Aâ?�
if [location] = â?�WORKâ?� then result = â?�Bâ?�
Example 2: (this works too but only as one line)
dim output as double
if [LOCATIONID]=100 then output=100 else if [LOCATIONID] = 101 then output = 101 else output = 102
Example 3: The following code will work BUT will give the wrong result!!
dim output as double
if [LOCATIONID] = 100 then output = 100 else
if [LOCATIONID] = 101 then output = 101 else output = 102
Example 4: This is the way it should work, but the line breaks must be correct.
dim output as double
if [LOCATIONID] = 100 then
output=100
elseif [LOCATIONID] = 101 then
output = 101
else
output = 102
end if
If thereâ??s anything following the â??thenâ?? it assumes a single-line format which, of course, is quite different from the multi-line format.
Example 5: An alternative form is the SELECT CASE â?¦ CASE â?¦ ELSE ... END SELECT format, which seems to be a tad more consistent:
dim output as double
select case [LOCATIONID]
case 100
output = 101
case 101
output = 100
case 102
output = 104
else
output = 0
end select
Good luck!
Jim G.
MN Dept. Of Agriculture