3

I am trying to do a simple labelling exercise.

However, I am a bit stuck on how to remove unwanted '0' values. I have three fields which I would like to display in a stacked label i.e. on three lines. However the third field has a number of 0 values which I would like to disappear - i.e. instead of having:

Field One
Field Two
0

I would like to have:

Field One
Field Two
Blank

2 Answers 2

8

Next to the label field click the "expression" button, then "advanced" checkbox and write a function in VBScript, JScrip or Python (choose the parser at the bottom). In this case 0 is an integer, if '0' use that. The Verify button tests it.

It expects a return called "FindLabel" so you have to use that name.

Here is a VBScript example

Function FindLabel ( [Field1] , [Field2] , [Field3])
If [Field3] <> 0 Then 
FindLabel = [Field1] & " " & [Field2] & " " & [Field3]
Else FindLabel = [Field1] & " " & [Field2]
End If
End Function

The label field will then show <expression> and the label will be "Field1 Field2 field3" if Field3 is not equal to 0, and "Field1 Field2" if it is.

0
2

You are asking about creating a label expression.

Advice is given in the help at Building label expressions but there is also someone's teaching material at Mastering Expressions which looks helpful.

Not the answer you're looking for? Browse other questions tagged or ask your own question.