I am trying to perform a semi-complicated labeling expression that shows one field divided by another field and some additional fields with no division. The issue I ran into was that the denominator sometimes shows up as a 0. So, I need to build an if statement to perform the division if [TOT_HH_1] <> 0, do __ and if [TOT_HH_1] = 0, do __.
Also, there are three denominators that may or may not be 0. TOT_HH_1, 5 and 10.
Here is what I have so far.
Function FindLabel ([ELEM_1], [TOT_HH_1], [ELEM_5], [TOT_HH_5], [ELEM_10], [TOT_HH_10] )
if ( [TOT_HH_1] <> 0 OR [TOT_HH_5] <> 0 OR [TOT_HH_10] <> 0) then
FindLabel = Round ([ELEM_1] / [TOT_HH_1] , 2) & " , " & Round ( [ELEM_5]/ [TOT_HH_5] , 2) & " , " & Round ( [ELEM_10] / [TOT_HH_10] , 2) & "/" & [TOT_HH_1] & " , " & [TOT_HH_5] & " , " & [TOT_HH_10]
elif ( [TOT_HH_1] = 0 ) then
FindLabel = 0 & " , " & Round ( [ELEM_5]/ [TOT_HH_5] , 2) & " , " & Round ( [ELEM_10] / [TOT_HH_10] , 2) & "/" & [TOT_HH_1] & " , " & [TOT_HH_5] & " , " & [TOT_HH_10]
End Function
Edit:
Correct, the code in the answer worked great, here is a picture of what the labeling looks like.