Solved

# Null values in nodes descriptions on a treeview

Posted on 2013-07-01
532 Views
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
Question by:yahooooo
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 9

Expert Comment

ID: 39292011
How about using the IsNull function?

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

LVL 61

Accepted Solution

mbizup earned 500 total points
ID: 39292013
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

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final pâ€¦
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filledâ€¦
###### Suggested Courses
Course of the Month5 days, 10 hours left to enroll