loading an empty DB field in Tree
How can I insert a field from a DB that is empty in to a tree as a child. I know the field is empty I just can't get it to load. I tried this
Code:
If IsNull(rsRoutines.Fields("Description")) Then
tvwMain.Nodes.Add "Routine" & rsRoutines("ParentID"), _
tvwChild, "Routine" & rsFiltered("counter"), _
rsFiltered("Routine"), "closed", "open"
but it comes back and tells me "element not found" and highlights the code above but points to the bold line
this is the full code
Code:
Set rsRoutines = dbName.OpenRecordset("SELECT * FROM Routine " _
& "ORDER BY ParentID, Routine") ', dbOpenSnapshot)
Dim SelectString As String
SelectString = "Select * from Routine where [Counter]= " + Label2
Set rsFiltered = dbName.OpenRecordset(SelectString)
Do While Not rsFiltered.EOF
?'Add routine nodes
If rsRoutines.Fields("ParentID") > "0" Then
tvwMain.Nodes.Add "Routine" & rsRoutines("ParentID"), _
tvwChild, "Routine" & rsFiltered("counter"), _
rsFiltered("Routine"), "code", "codered"
If IsNull(rsRoutines.Fields("Description")) Then
tvwMain.Nodes.Add "Routine" & rsRoutines("ParentID"), _
tvwChild, "Routine" & rsFiltered("counter"), _
rsFiltered("Routine"), "closed", "open"
End If
End If
rsFiltered.MoveNext
Loop
rsRoutines.MoveNext
Loop
the first if..then works fine it is the second one that doesn't. What am I doing wrong?
TIA
Just got your post in chit chat
Looks real complex, will have a muck around with it. Whoa, second support call..............bug:eek:
Oh okay, they don't have the latest service pack. Damn, back to pretending l'm awake.
Re: loading an empty DB field in Tree
Quote:
Originally posted by scoutt
How can I insert a field from a DB that is empty in to a tree as a child. I know the field is empty I just can't get it to load. I tried this
Code:
If IsNull(rsRoutines.Fields("Description")) Then
tvwMain.Nodes.Add "Routine" & rsRoutines("ParentID"), _
tvwChild, "Routine" & rsFiltered("counter"), _
rsFiltered("Routine"), "closed", "open"
but it comes back and tells me "element not found" and highlights the code above but points to the bold line
this is the full code
Code:
Set rsRoutines = dbName.OpenRecordset("SELECT * FROM Routine " _
& "ORDER BY ParentID, Routine") ', dbOpenSnapshot)
Dim SelectString As String
SelectString = "Select * from Routine where [Counter]= " + Label2
Set rsFiltered = dbName.OpenRecordset(SelectString)
Do While Not rsFiltered.EOF
?'Add routine nodes
If rsRoutines.Fields("ParentID") > "0" Then
tvwMain.Nodes.Add "Routine" & rsRoutines("ParentID"), _
tvwChild, "Routine" & rsFiltered("counter"), _
rsFiltered("Routine"), "code", "codered"
If IsNull(rsRoutines.Fields("Description")) Then
tvwMain.Nodes.Add "Routine" & rsRoutines("ParentID"), _
tvwChild, "Routine" & rsFiltered("counter"), _
rsFiltered("Routine"), "closed", "open"
End If
End If
rsFiltered.MoveNext
Loop
rsRoutines.MoveNext
Loop
the first if..then works fine it is the second one that doesn't. What am I doing wrong?
TIA
Hahahahahaha. Nice one Jethro.
HB, I'm sure that this site is for VB posts only but its still nice to have some fun around. Don't be to serious. Man, laugh it off.
As to the problem at hand, hope this could help.
'The second if.
Assumptions:
Make sure that you really have a "Description" field in your table.
Make sure that the Key in you imgcontrol are the same as you are using it now. ("Closed" <> "closed")
'Since only when your description is null you want to add.
If len(trim(rsRoutines.Fields("Description")& "")) = 0 Then
tvwMain.Nodes.Add "Routine" & rsRoutines("ParentID"), _
tvwChild, "Routine" & rsFiltered("counter"), _
rsFiltered("Routine"), "closed", "open"
End If