|
-
May 24th, 2001, 07:26 PM
#1
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
-
May 25th, 2001, 07:55 AM
#2
Well ...
Instead of "closed" and "open" you should use the indexes of the images from the ImageList control.
If you are using the key values of the images, chances are that these images are missing, or there are no images with key values "closed" and "open" in the ImageList control.
.
-
May 25th, 2001, 05:59 PM
#3
I tried it but it didn't work. the "closed", "open" images are in the imageslist and it uses it in another part of the code. Could it be that rsFiltered is looking at the counter (in the SelectString) instead of Description?
It still gives me that error of "Element not found" runtime error 35601.
-
May 25th, 2001, 07:22 PM
#4
Just got your post in chit chat
Looks real complex, will have a muck around with it. Whoa, second support call..............bug
Oh okay, they don't have the latest service pack. Damn, back to pretending l'm awake.
-
May 25th, 2001, 07:25 PM
#5
Hmmm.....
have you tried replacing Isnull with Len(Trim()) > 0 and using = "" &
-
May 25th, 2001, 10:15 PM
#6
Well ...
<Comments about Jethro have been removed.>
Scoutt, the field name and table name "Routine" look the same. Could that be the cause of trouble?
Try changing the field name to something else.
.
Last edited by honeybee; May 28th, 2001 at 02:01 AM.
-
May 26th, 2001, 12:19 AM
#7
I didn't even notice that. I will change one and get back with ya. thanks Honeybee for seeing that.
-
May 26th, 2001, 03:36 AM
#8
well,
I changed the name of the table and it still gives me the error, anymore ideas??
-
May 27th, 2001, 05:12 PM
#9
Re: Well ...
Originally posted by honeybee
Jethro, don't act like you are a support guy for MS, totally meaningless advice which should really go to Chit Chat.
.
And the horse you rode in on arsehole. This sort of comment is the type that gives you a bad name. All l can so is "go take a flying f**k at a rolling donut. Clearly l'm am nopt up to your esteemed level of vb expertised. Sorry, but l don't give a rats arse mate.
-
May 27th, 2001, 05:38 PM
#10
PowerPoster
-
May 27th, 2001, 10:51 PM
#11
PowerPoster
HB DONT DISRESPECT OTHER MEMBERS OF THIS FORUM.
Jethro's a top bloke dont insult people you should know better!
And he's a top programmer!
I would also like you too know he probably wasnt trying to be a MS support dude rather talking about the company he works for. Most probably getting a call from a company he's worked for about a program he did or something.
Eat your words my friend.
-
May 28th, 2001, 02:14 AM
#12
PowerPoster
BLOODY HELL. COME BACK BOTH OF YOU!
-
May 28th, 2001, 03:27 AM
#13
Well ...
Originally posted by Jethro
Ok got the facts now.
1. On Saturday Jethro was holding down our help desk. And no we are not Microsoft.
2. Posted he was bored and Scoutt asked him to have a look at this issue.
3. His suggestion re: trim(len( is an acceptable attempt to check the error that Scoutt is getting.
4. So who the f**k is Honeybee. SOunds like he is ever a visual basic master or a site administrator.
5. From his posts, (other threads included), this is clearly not the case.
Actually Dave Munro signing off here as well. Want even bothered with my own Login to this site. Cleary, as Jethro has discovered, life is too short too put up with pissants like Honeybee. Congratulations Buddy, you have managed to alienate at least two other people from this site.
Look, Dave Munro, I am not gonna eat my words, but if they are too insulting, I have removed them. I am sorry I have been such a great piss-off for you two.
Beacon, I tried to send an IM to Jethro, but looks like it's not gonna work now. Can you request the Aussie Jethro to get in touch with me by email on [email protected] ? I doubt if he will bother, but can you just try, as a favour to me?
And now please let's move to Chit Chat to discuss this.
.
-
May 28th, 2001, 11:40 AM
#14
Whoa??? calm down guys.
can't we al just be friends, and this still didn't solve my problem.
somebody must know how to load a DB filed that is empty to a treeview.
-
May 28th, 2001, 03:59 PM
#15
update
I know have this code which seems to work except it loads everything that I want as folders as regular child nodes. i.e. uses "code", "codered" instead of "closed", "open"
Code:
If IsNull(rsDescript.Fields("Description")) Then
tvwMain.Nodes.Add "Routine" & rsRoutines("ParentID"), tvwChild, _
"Routine" & rsRoutines("counter"), _
rsRoutines("Routine"), "closed", "open"
ElseIf rsRoutines("ParentID") > "0" Then
tvwMain.Nodes.Add "Routine" & rsRoutines("ParentID"), tvwChild, _
"Routine" & rsFiltered("counter"), _
rsFiltered("Routine"), "code", "codered"
End If
I don't get any errors, but it acts like it just passes the IsNull statement with out executing it.
-
May 28th, 2001, 06:15 PM
#16
Originally posted by scoutt
Whoa??? calm down guys.
can't we al just be friends, and this still didn't solve my problem.
somebody must know how to load a DB filed that is empty to a treeview.
Good call, except clearly l am posting lame comments, that don't deserve your review.
Ok am looking at this "null" string thing. Have actual prove that
Dim String as String.
String = "" & rs!Name
Len(trim(String) can return 0
while
IsNull(String) can return False.
Have just looked on local site where l posted this issue, (maybe lame but have 10 ppl interested in it), and the consensus at the moment is that IsNull can return False regardless of situation, even if it should logically produce true.
This is truely weird.
-
May 28th, 2001, 07:29 PM
#17
so is there anything else I can use to get it to load a blank field besides IsNull? And yes I have tried to use =""
You would think that this problem wouldn't be so difficult. all I am trying to do is load a field as a child but with the folder images. I am sure one of these DB gurus knows how,
thanks Jethro for giving it a shot and finding out what you did.
-
May 28th, 2001, 09:00 PM
#18
What's your exact setup. Our knowledge base just says don't use IsNull. Apparently if you dim a value, and then try and load an object which doesn't exist, it sets the value to a blank. Therefore if you use the function IsNull() returns False cause the variable you are testing has been set to blank not Null. The SQL guys are saying they use a function which by-passes this completely, but which ain't available in vb.
-
May 28th, 2001, 09:13 PM
#19
Addicted Member
Re: loading an empty DB field in Tree
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
-
May 28th, 2001, 09:59 PM
#20
Well
Rives, thanks but I still get the same error. "element not found" points to the same code as above.
however since the problems has eluded the best of us, I added another field in the DB and put a number there so I can refence it in the code and know it works just fine. So now every null Description Field can be a child folder.
I want to thank everybody that tried to fix this problem.
And Jethro, cheer up bud.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|