x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 552

# Null values in nodes descriptions on a treeview

Guys

I wonder if it's possible to sort out nulls among items which I display as a node description.
In this case a have few ABC Indicators which are null so I'd avoid changing their value to N/A and add some if statement to omit them. I tried to equal it to null and iserror but no luck.
As you can see below I tried Nz() as well

``````                            If Nz(CStr(PS![ABC Indicator])) = "A" Then
Set a = TreeView.Nodes.Add(CStr(PS![Superior Function Location]), tvwChild, CStr(PS![Functional location]), CStr(PS![Functional location]) & "     (" & CStr(PS![Function Location Description]) & ")" & "     (" & Nz(CStr(PS![ABC Indicator])) & ")" & "     (" & CStr(PS![Object type]) & ")" & "     (" & CStr(PS![Object Type Desc]) & ")")
a.ForeColor = RGB(63, 23, 127) 'violet
ElseIf Nz(CStr(PS![ABC Indicator])) = "B" Then
Set a = TreeView.Nodes.Add(CStr(PS![Superior Function Location]), tvwChild, CStr(PS![Functional location]), CStr(PS![Functional location]) & "     (" & CStr(PS![Function Location Description]) & ")" & "     (" & Nz(CStr(PS![ABC Indicator])) & ")" & "     (" & CStr(PS![Object type]) & ")" & "     (" & CStr(PS![Object Type Desc]) & ")")
a.ForeColor = RGB(255, 97, 3) 'orange
ElseIf Nz(CStr(PS![ABC Indicator])) = "C" Then
Set a = TreeView.Nodes.Add(CStr(PS![Superior Function Location]), tvwChild, CStr(PS![Functional location]), CStr(PS![Functional location]) & "     (" & CStr(PS![Function Location Description]) & ")" & "     (" & Nz(CStr(PS![ABC Indicator])) & ")" & "     (" & CStr(PS![Object type]) & ")" & "     (" & CStr(PS![Object Type Desc]) & ")")
a.ForeColor = RGB(24, 116, 205) 'blue
Else
Set a = TreeView.Nodes.Add(CStr(PS![Superior Function Location]), tvwChild, CStr(PS![Functional location]), CStr(PS![Functional location]) & "     (" & CStr(PS![Function Location Description]) & ")" & "     (" & CStr(PS![Object type]) & ")" & "     (" & CStr(PS![Object Type Desc]) & ")")
End If
``````
0
yahooooo
1 Solution

Commented:
How about using the IsNull function?

If IsNull([ABC Indicator]) Then
...
0

Commented:
Are you getting errors with NZ?  The NZ should be inside the Cstr:

``````If CStr(NZ( PS![ABC Indicator], "")) = "A"
``````

This is an alternative:

``````If CStr("" & PS![ABC Indicator]) = "A" Then
``````

Also - I dont think the CStr is needed at all...

``````If "" & PS![ABC Indicator] = "A" Then
``````
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.