TreeView Help Help Help

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Need help with tree View

I have a treeview control on a form & I can populate the first level
But seem to be going round in circles when it comes to the second leg.
The first level is using a query “qryPowderB” that shows the Batch_ID &
Name, the name of the batch.

The second level is also using a query “qryTVPBMIX”
Displays
Batchid this is equal to Batch_ID from the other query
MIBatch this is the Batch number given as a name
Rawmatt this is the raw material type


What I want to do is display a batch with name 1200 then display all the sub
batches associated with it.

Not sure why but I keep getting Key is not unique in collection, in the VB
editor Me!axTreeView.Nodes.Add RS!Batchid.Value, tvwChild, StrOrderKey, _
RS!MIBatch & " " & RS!Rawmatt
Is highlit yellow but I cant debug it, don’t know how?

The bellow is the sql code for the querys & the vb code for my tree view
HELP HELP HELP HELP pleeeeas??

qryPowderB

SELECT "o" & [MECHT_ID] AS Batch_ID, tblPowderbatches.[BATCH#] AS Name
FROM tblPowderbatches;


qryTVPBMIX


SELECT "o" & [NPOW-ID] AS Batchid, tblPowdermix.[MI-Batch] AS MIBatch,
IIf([Rawmat]=1,"Tungsten",IIf([Rawmat]=2,"Nickel",IIf([Rawmat]=3,"Iron",IIf([Rawmat]=4,"Copper",IIf([Rawmat]=5,"Molydbneyum","HA/HE"))))) AS Rawmatt
FROM tblPowdermix;



VB Code

Private Sub Form_Load()

Dim DB As DAO.Database, RS As DAO.Recordset
Dim StrOrderKey As String

Set DB = CurrentDb

' Open a Recordset and loop through it to fill the TreeView
' control.
' The Key value, RS!Batch_ID, is naturally alphabetical

Set RS = DB.OpenRecordset("qryPowderB", dbOpenDynaset, abReadOnly)
Do Until RS.EOF
Me!axTreeView.Nodes.Add , , RS!Batch_ID, RS!Name
RS.MoveNext
Loop
RS.Close

' Fill Level 2.
Set RS = DB.OpenRecordset("qryTVPBMIX", dbOpenForwardOnly)
Do Until RS.EOF
' Link to Level 1 by referencing the Batchid key and set
' the node as a child node of Level 1. Use "o" and the
' StrConv() function in the new Key property for Level 2,
' because MIBatch is a numeric field.
StrOrderKey = StrConv("o" & RS!MIBatch, vbLowerCase)
Me!axTreeView.Nodes.Add RS!Batchid.Value, tvwChild, StrOrderKey, _
RS!MIBatch & " " & RS!Rawmatt
RS.MoveNext
Loop
RS.Close

Set RS = Nothing
Set DB = Nothing


End Sub

.



Relevant Pages

  • RE: Search Treeview
    ... "Wibberlet" wrote: ... building the tree to enable you to use the Findmethod effectively. ... I did this is VB6 with no problem, but as we all know, the Treeview control ... recursion) starting at the top and going through all nodes until found or at ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: what is the correct data structure to use with this problem?
    ... I'm just stumped with how the tree should look... ... >false query and move to the next, retaining the fact that the false ... You save time in each rule evaluating P1 assuming ... >> queries) but I hope it clarifies. ...
    (comp.programming)
  • Re: Easier access to PropertyInfo
    ... The connections are made between properties of nodes. ... the tree represents a query to a custom datamodel. ... be evaluated in the correct order, and then their update methods are ...
    (microsoft.public.dotnet.languages.csharp)
  • question about/problem with tree view
    ... I have a form with a tree on it. ... a query hits the database ... and then I iterate through the query results and each record returned ... I never really set the window state to maximized... ...
    (comp.lang.pascal.delphi.misc)
  • RE: HOW TO: Treeview, obtain the first node index in a sorted Tree
    ... query alphabetically and determine the associated with that first ... "Kevin McCartney" wrote: ... for it in the treeview to return its index. ... the tree and if it the text started with a Z it would appear at the bottom. ...
    (microsoft.public.access.formscoding)