Results 1 to 6 of 6

Thread: TreeView - What am I doing wrong?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    82

    TreeView - What am I doing wrong?

    I have the following code to add the root level to a treeview control:
    Code:
    Set nodX = TreeView1.Nodes.Add(, , "lvl1" & m_rsLevel1!strDesc, m_rsLevel1!strDesc)
    I've done this a billion times in the past, but this keeps giving me a "Type Mismatch" error. The field "strDesc" is a string, so the key should be ok. Can anyone kick me the butt and face me the right way?? Thanks.

  2. #2
    khalik
    Guest
    MSDN..


    [code]

    TV1.Add(relative, relationship, key, text, image, selectedimage)

    tvwFirst 0 First. The Node is placed before all other nodes at the same level of the node named in relative.
    tvwLast 1 Last. The Node is placed after all other nodes at the same level of the node named in relative. Any Node added subsequently may be placed after one added as Last.
    tvwNext 2 (Default) Next. The Node is placed after the node named in relative.
    tvwPrevious 3 Previous. The Node is placed before the node named in relative.
    tvwChild 4 Child. The Node becomes a child node of the node named in relative.

    [code/]

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    82
    Thanks, khalik

    I can make the TreeView work if I do not try to set the node "nodX". However, by doing that, I lose out on being able to use the "forecolor" property. So, I have to perform the assignment as:

    "set nodX = ..."

  4. #4
    khalik
    Guest
    Originally posted by Jeff Carlin
    Thanks, khalik

    I can make the TreeView work if I do not try to set the node "nodX". However, by doing that, I lose out on being able to use the "forecolor" property. So, I have to perform the assignment as:

    "set nodX = ..."
    [code]
    Dim nodX As Node ' Declare Node variable.
    ' First node with 'Root' as text.
    Set nodX = TreeView1.Nodes.Add(, , "r", "Root")


    ' This next node is a child of Node 1 ("Root").
    Set nodX = TreeView1.Nodes.Add("r", tvwChild, "child1", "Child")

    [code/]
    node does not have the use the "forecolor" property
    what are u looking for.

  5. #5
    Fanatic Member Slaine's Avatar
    Join Date
    Jul 2002
    Posts
    641
    Jeff,

    I tried your code and it worked ok for me. All I can think is that the field m_rsLevel1!strDesc contains something dodgy. What are the contents of this when you get the error? What is the datatype of the field?

    I managed to recreate the error message by passing Null instead of m_rsLevel1!strDesc. Could be that the recordset is empty.
    Martin J Wallace (Slaine)

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    82
    Slaine:

    That'w what's so wacky! The recordset is full and I can see a value when the error hits. Without doing the assignment (Set xNod = ...), the sucker works. I'm starting to think that it's something in the Dim statement: Dim xNod As Node

    (30 seconds later...)

    Ah...just found it. Typical dumba$$ error. I had referenced "comctl32" instead of "mscomctl". Boom. Problem solved. Thanks.

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