Solved

treeview control in vb6 - kep value error

Posted on 2004-03-29
4
315 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

864 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now