TreeView Help Help Help
- From: Jedit <Jedit@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 28 Mar 2006 03:13:02 -0800
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
.
- Follow-Ups:
- Re: TreeView Help Help Help
- From: Graham Mandeno
- Re: TreeView Help Help Help
- Prev by Date: Re: Referencing ad-hoc tables on forms..
- Next by Date: Re: cmdButton SendObject that attaches pdf file
- Previous by thread: Re: DLookup Problem !
- Next by thread: Re: TreeView Help Help Help
- Index(es):
Relevant Pages
|