• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

treeview control in vb6 - kep value error

I am trying to use treeview control in vb6. Its giving error with the key parameter as invalid key value when I am trying to add nodes at run time.
what type of value does the key parameter takes (String / int) ?
please help
  • 2
1 Solution
The key must be a string, that is it must at least start with an alpha.  Then it can be alpha or numeric.

Many people (include me) want to use the key to hold an ID to the database.  What I do is append the letter K in front of the actual ID

Dim strKey as String
strKey = "K" & rs.fields("ID")
rk75Author Commented:
I got the solution. I was trying to assign a number as a string as key of a node.
I tried the concatenated alphanumeric value starting with an alpha and it worked!!!

don't forget to grade it so the question is closed and I get the points.

Glad I could help.
Dear Friend

it will take parameter of string type. u can c this small code. I hope it will help u.

Private Sub LoadTree()
    Dim intCounter As Integer

    On Error GoTo errHandler
    Call OpenConnection
    strQuery = "SELECT * FROM tblSupplierMaster ORDER BY Name"
    Set objRdo = objConn.Execute(strQuery)
    While Not objRdo.EOF
        Set XNode = treeviewSupplier.Nodes.Add(, , "Key " & objRdo("SupplierCode"), objRdo("Name"))
    Call CloseConnection
    Exit Sub
    MsgBox Err.Description, vbCritical, ERROR_CAPTION
End Sub

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now