Solved

treeview control in vb6 - kep value error

Posted on 2004-03-29
4
319 Views
Last Modified: 2008-03-17
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
0
Comment
Question by:rk75
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
SRigney earned 25 total points
ID: 10707355
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")
0
 

Author Comment

by:rk75
ID: 10707477
Thanks!!
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!!!

0
 
LVL 15

Expert Comment

by:SRigney
ID: 10707506
don't forget to grade it so the question is closed and I get the points.

Glad I could help.
0
 

Expert Comment

by:tomerps1
ID: 10738898
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"))
        objRdo.MoveNext
    Wend
   
    objRdo.Close
    Call CloseConnection
   
    Exit Sub
   
errHandler:
    MsgBox Err.Description, vbCritical, ERROR_CAPTION
End Sub


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question