Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading Treeview

Status
Not open for further replies.

aclayborne

Programmer
May 3, 2000
49
US
I'm using this code to populate a treeview control it give me a 35603 runtime error &quot;invalid key&quot;. PCID is a char type. What is wrong with the code.<br><br><br>If rs.RecordCount &gt; 0 Then<br>&nbsp;&nbsp;&nbsp;rs.MoveFirst<br>&nbsp;&nbsp;&nbsp;Do Until rs.EOF<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If Trim(rs.Fields(&quot;PCID&quot;)) &lt;&gt; prevPCID Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set oNodex = TreeView1.Nodes.Add(, , Trim(rs.Fields(&quot;PCID&quot;)), Trim(rs.Fields(&quot;PCID&quot;)))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prevPCID = Trim(rs.Fields(&quot;PCID&quot;))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If Trim(rs.Fields(&quot;Description&quot;)) &lt;&gt; prevDesc Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set oNodex = TreeView1.Nodes.Add(Trim(rs.Fields&nbsp;&nbsp;&nbsp;&nbsp;(&quot;PCID&quot;)), tvwChild, Trim(rs.Fields(&quot;Description&quot;)), Trim(rs.Fields(&quot;Description&quot;)))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prevDesc = Trim(rs.Fields(&quot;Description&quot;))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs.MoveNext<br>&nbsp;&nbsp;&nbsp;&nbsp;Loop<br>End If
 
Without seeing the contents of your table,&nbsp;&nbsp;I suspect that the value starts with a numeric character.&nbsp;&nbsp;Keys must start with an Alpha character, even if your field is a string. <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
Thanks I added a &quot;_&quot; before the field and it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top