Cguizzardi
New member
- Local time
- Tomorrow, 08:40
- Joined
- May 3, 2023
- Messages
- 7
Dear All
i m sorry to post this topic but i spend all evening of the last 2 weeks without get any good results.
i m trying to add nodes to the Tree view control on Access, but basically i have 2 cases:
1 - if i stop to the first level of nodes i don't have any issue but when i go to the seconds i get the error related to the not unique key
2- i m trying to add the condition where to the vba code but i m not able to set the correct words for the Where condition on the sql string
i m sorry to post this topic but i spend all evening of the last 2 weeks without get any good results.
i m trying to add nodes to the Tree view control on Access, but basically i have 2 cases:
1 - if i stop to the first level of nodes i don't have any issue but when i go to the seconds i get the error related to the not unique key
2- i m trying to add the condition where to the vba code but i m not able to set the correct words for the Where condition on the sql string
Code:
Private Sub cmdCarica_Click()
Dim tempNode As MSComctlLib.Node
Dim rsSys As DAO.Recordset 'contiene i record dei systemi
Dim rsSSys As DAO.Recordset 'contiene i record dei Sotto Sistemi
Dim rsItem As DAO.Recordset 'contiene i record degli Item
Dim rsAct As DAO.Recordset 'contiene i record delle attività
tv.Nodes.Clear
Set tempNode = tv.Nodes.Add(, , "S", "Project")
Set rsSys = CurrentDb.OpenRecordset("SELECT DISTINCT Qry_Progress.[System Number], Qry_Progress.[System Name]FROM Qry_Progress ORDER BY Qry_Progress.[System Number]", , dbReadOnly)
Do While Not rsSys.EOF
'CARICO I SYSTEMI
Set tempNode = tv.Nodes.Add("S", _
tvwChild, _
"SYS" & rsSys.Fields("System Number"), _
rsSys.Fields("System Number") & " - " & rsSys.Fields("System Name"))
'CARICO I SOTTO-SYSTEMI
Set rsSSys = CurrentDb.OpenRecordset("SELECT DISTINCT Qry_Progress.[Sub System Number], Qry_Progress.[Sub System Name] FROM Qry_Progress WHERE Qry_Progress.[Sub System Number] = ""rsSys.Fields("Sub System Number")"" ORDER BY Qry_Progress.[Sub System Number]", , dbReadOnly)
Do While Not rsSSys.EOF
Set tempNode = tv.Nodes.Add("SYS" & rsSys.Fields("System Number"), _
tvwChild, _
"Sub_SYS" & rsSSys.Fields("Sub System Number"), _
rsSSys.Fields("Sub System Number") & " - " & rsSSys.Fields("Sub System Name"))
'
' 'CARICO GLI ITEM
' Set rsItem = CurrentDb.OpenRecordset("SELECT DISTINCT Qry_Progress.[TAG NO], Qry_Progress.[Tag Name] FROM Qry_Progress", , dbReadOnly)
' Do While Not rsItem.EOF
' Set tempNode = tv.Nodes.Add("Sub_SYS" & rsSSys.Fields("Sub System Number"), _
' tvwChild, _
' "Item" & "Sub_SYS" & rsSSys.Fields("Sub System Number") & rsItem.Fields("TAG NO"), _
' rsItem.Fields("TAG NO") & " - " & rsItem.Fields("Tag Name"))
'
' ' 'CARICO LE ATTIVITà
' ' Set rsAct = CurrentDb.OpenRecordset("SELECT DISTINCT Qry_Progress.[BASIC ACTIVITY LIST], Qry_Progress.[ITR Form] FROM Qry_Progress", , dbReadOnly)
' ' Do While Not rsAct.EOF
' 'Set tempNode = tv.Nodes.Add("Item" & rsItem.Fields("TAG NO"), _
' tvwChild, _
' "ACT" & rsAct.Fields("BASIC ACTIVITY LIST"), _
' rsAct.Fields("BASIC ACTIVITY LIST") & " - " & rsAct.Fields("ITR Form"))
' 'rsAct.MoveNext
' 'Loop
' rsItem.MoveNext
' Loop
'
rsSSys.MoveNext
Loop
rsSys.MoveNext
Loop
rsSys.Close
rsSSys.Close
'rsItem.Close
'rsAct.Close
End Sub