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

Any ideas welcomed - as you will guess I am fairly new at this so all help appreciated.

6

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.

| improve this answer | |
  • Thanks this works! I modified " " to vbNewLine to get stacked labels but otherwise it worked perfectly. – user2903445 Nov 19 '13 at 10:52
1

You are asking about creating a label expression, advice is given here, there is also someone's teaching material here which looks helpful.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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