I am attempting to populate a VB6 TreeView from a Recordset that holds Appointment Data. The TreeView Structure is Staff/Resource (Parent), AppointmentType (Child), Appointments (GrandChild).
As I iterate through all appointments in recordset, which e.g has only 1 Parent, 3 Children and 20 GrandChildren; I am unsure how to only create the RootNode once and ChildNode 3 times. The Grandchildren are easy as they are required through each Loop.
I would like to use a DISTINCT query on the Recordset to get my Node Levels but have found this impossible.
Dim queryAll as String
Dim appRS as object
Dim NodeX as Node
queryAll = "SELECT * FROM Appointment WHERE appDate = CURDATE() ORDER BY Staff/Resource, appontmentType, startTime"
Set appRS = gDBUtility.getRSA(queryAll)'This populates RS.
If Not appRS Is Nothing Then
While Not appRS.EOF
'I understand all the Add Nodes syntax
Set NodeX = TreeView1.Nodes.Add(,,aappRS!Staff,appRS!Staff)
' However above will create the same node every time and Crash.
Set NodeX = tv1.Nodes.Add(appRS!Staff,tvwChild,appRS!uniqueKey,appRS!appointmentType)
Set appRS = Nothing