Tried my best at a VBScript label expression in ArcGIS Pro. The expression is 'valid', but the results are that nothing labels at all. Basically, I want my address points to only label with the [Address] field, when [Building] and [Unit] are both null. If [Building] is not null, but [Unit] is null, I want the label to display the [Address] followed on the next line by the [Building]. If [Unit] is not null, but [Building] is null, I want the label to display the [Address] followed on the next line by the [Unit]... if that makes sense.
I appreciate any help! My function is written as follows:
Function FindLabel ( [Address], [Building], [Unit] )
If (IsNull[Unit]) And (IsNull[Building]) Then
FindLabel = [Address]
ElseIf (Not IsNull[Building]) And (IsNull[Unit]) Then
FindLabel = [Address] + vbNewLine + [Building]
ElseIf (IsNull[Building]) And (Not IsNull[Unit]) Then
FindLabel = [Address] + vbNewLine + [Unit]
End If
End Function
Solved! Go to Solution.
There's a problem where the validator is not catching the errors where you are leaving off parentheses in the IsNull functions. Instead of "IsNull[Unit]", it should be "IsNull([Unit])"
Your code should look like this
Function FindLabel ( [Address], [Building], [Unit] )
If (IsNull([Unit])) And IsNull([Building])) Then
FindLabel = [Address]
ElseIf (Not(IsNull([Building])) And IsNull([Unit])) Then
FindLabel = [Address] + vbNewLine + [Building]
ElseIf (IsNull([Building]) And Not(IsNull([Unit]))) Then
FindLabel = [Address] + vbNewLine + [Unit]
End If
End Function
There's a problem where the validator is not catching the errors where you are leaving off parentheses in the IsNull functions. Instead of "IsNull[Unit]", it should be "IsNull([Unit])"
Your code should look like this
Function FindLabel ( [Address], [Building], [Unit] )
If (IsNull([Unit])) And IsNull([Building])) Then
FindLabel = [Address]
ElseIf (Not(IsNull([Building])) And IsNull([Unit])) Then
FindLabel = [Address] + vbNewLine + [Building]
ElseIf (IsNull([Building]) And Not(IsNull([Unit]))) Then
FindLabel = [Address] + vbNewLine + [Unit]
End If
End Function
Argh! Lol. So frustrating! THANK YOU! It's a learning process for sure.