# ArcMap: Help with FindLabel funtion

I'm starting to work with the advanced findlabel function in ArcMap label expression editor. I will say I'm a complete novice at this up front. Here is what I have so far:

``````Function FindLabel ( [SwineWeFin] , [SwineGrFin] , [SwineNurse] , [SwineGesBo] , [SwineSowLt] , [SwineGilti] , [CattleDaHl] , [CattleDaJr] , [CattleDaHf] , [CattleBeFn] , [CattleBeFe] , [CattleVeal] , [TurkeyFin] , [TurkeyPlBr] , [ChickenLBr] , [ChickenPul]     )

if ( [SwineWeFin]  > 0) then  FindLabel = [SwineWeFin] & " WTM "

if ( [SwineGrFin] > 0) then  FindLabel = [SwineGrFin] & " FTM"

if ( [SwineNurse]  > 0) then  FindLabel = [SwineNurse] & "Nursery"

if ( [SwineGesBo] + [SwineSowLt]  > 0) then  FindLabel = [SwineGesBo] + [SwineSowLt]  & "Sows"

if ( [SwineGilti]  > 0) then  FindLabel = [SwineGilti]  & " Gilts"

if ( [CattleDaHl] +  [CattleDaJr] +  [CattleDaHf] +  [CattleBeFn] +  [CattleBeFe] +  [CattleVeal]  > 0) then FindLabel = "Cows"

if ( [TurkeyFin] + [TurkeyPlBr]  > 0) then  FindLabel =  "Turkey"

if ( [ChickenLBr] + [ChickenPul]  > 0) then  FindLabel = "Chickens"

End Function
``````

This mess actually works for me. The problem that I have is when two or more of the "if' criteria apply to the same point. Currently, the label will only show the first criteria that is found to be true. I want all criteria that are true to be shown as a label. I would prefer if it showed each TRUE item on a new line for the label.

Is what I'm wanting to do even possible? And if so, how would I script it? Thanks!!!!

• You might also consider redesigning your database so that all this logic is not needed. Jan 14, 2013 at 19:57

What you'll want to do is something like this.

``````Function FindLabel ( [SwineWeFin] , [SwineGrFin] , [SwineNurse] , [SwineGesBo] , [SwineSowLt] , [SwineGilti] , [CattleDaHl] , [CattleDaJr] , [CattleDaHf] , [CattleBeFn] , [CattleBeFe] , [CattleVeal] , [TurkeyFin] , [TurkeyPlBr] , [ChickenLBr] , [ChickenPul] )

if ( [SwineWeFin] > 0) then output = [SwineWeFin] & " WTM "
if len(output) > 0 then output = output & vbNewLine
if ( [SwineGrFin] > 0) then output = output & [SwineGrFin] & " FTM"
if len(output) > 0 then output = output & vbNewLine
if ( [SwineNurse] > 0) then output = output & vbNewLine & [SwineNurse] & "Nursery"
if len(output) > 0 then output = output & vbNewLine
if ( [SwineGesBo] + [SwineSowLt] > 0) then output = output & vbNewLine & [SwineGesBo] + [SwineSowLt] & "Sows"
if len(output) > 0 then output = output & vbNewLine
if ( [SwineGilti] > 0) then output = output & vbNewLine & [SwineGilti] & " Gilts"
if len(output) > 0 then output = output & vbNewLine
if ( [CattleDaHl] + [CattleDaJr] + [CattleDaHf] + [CattleBeFn] + [CattleBeFe] + [CattleVeal] > 0) then output = output & vbNewLine & "Cows"
if len(output) > 0 then output = output & vbNewLine
if ( [TurkeyFin] + [TurkeyPlBr] > 0) then output = output & vbNewLine & "Turkey"
if len(output) > 0 then output = output & vbNewLine
if ( [ChickenLBr] + [ChickenPul] > 0) then output = output & vbNewLine & "Chickens"

FindLabel = output

End Function
``````
• Great...don't forget to mark this as the answer. Jan 14, 2013 at 19:49