Results 1 to 20 of 20

Thread: loading an empty DB field in Tree

  1. #1
    scoutt
    Guest

    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

  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  3. #3
    scoutt
    Guest
    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.

  4. #4
    Jethro
    Guest

    Unhappy 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.

  5. #5
    Jethro
    Guest
    Hmmm.....

    have you tried replacing Isnull with Len(Trim()) > 0 and using = "" &

  6. #6
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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.
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  7. #7
    scoutt
    Guest
    I didn't even notice that. I will change one and get back with ya. thanks Honeybee for seeing that.

  8. #8
    scoutt
    Guest

    well,

    I changed the name of the table and it still gives me the error, anymore ideas??

  9. #9
    Jethro
    Guest

    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.

  10. #10
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    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.
    Nice one HB

  11. #11
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    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.

  12. #12
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    BLOODY HELL. COME BACK BOTH OF YOU!

  13. #13
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  14. #14
    scoutt
    Guest
    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.

  15. #15
    scoutt
    Guest

    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.

  16. #16
    Jethro
    Guest
    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.

  17. #17
    scoutt
    Guest
    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.

  18. #18
    Jethro
    Guest
    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.

  19. #19
    Addicted Member
    Join Date
    Sep 1999
    Location
    Philippines
    Posts
    196

    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

  20. #20
    scoutt
    Guest

    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
  •  



Click Here to Expand Forum to Full Width