X
x6v87qe
hi,everyone. I've got a problem with my treeview control.It's not happed all
the time
but for some of the computers. I used "date" as the node point for the
treeview,when click on a particular date , another subform will display
thecorresponding infor on this date. it works fine on my computer,HOWEVER,in
some other computers, it behavours like this:
1-7/8/2006- no disp, 8/8/2006-ok,9-12/8/2006-no dis, rest -ok
1-8/9/2006- no disp, 9/9/2006-ok,10-12/9/2006-no dis, rest -ok
1-9/10/2006- no disp, 10/10/2006-ok,11-12/10/2006-no dis, rest -ok
1-10/8/2006- no disp, 11/11/2006-ok,12/11/2006-no dis, rest -ok
Isn't it wierd ?!!! Here is my code:
___________________________________________
Sub AddMyTree()
On Error GoTo Err_AddMyTree
Dim conn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim nodCurrent As Node
Dim objTree As Object
Set objTree = Me.TreeView0
Set conn = CurrentProject.Connection
strSQL = "SELECT DISTINCT DateRec FROM Table1 GROUP BY DateRec"
rst.Open strSQL, conn, adOpenStatic, adLockReadOnly
Do While Not rst.EOF
Set nodCurrent = objTree.Nodes.Add(, , "a" & rst("DateRec"),
rst("DateRec"), 1, 2)
nodCurrent.Tag = rst("DateRec")
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Set conn = Nothing
Exit_AddMyTree:
Exit Sub
Err_AddMyTree:
Set rst = Nothing
Set conn = Nothing
MsgBox Err.Description, vbCritical, "AddMyTree"
Resume Exit_AddMyTree
End Sub
Private Sub Detail_Click()
End Sub
Private Sub TreeView0_NodeClick(ByVal Node As Object)
Dim strSQL As String
strSQL1 = "SELECT * FROM Table1 "
strSQL = strSQL1 & "WHERE DateRec = # " & CDate(Node.Tag) & " # "
Me.Table1_subform.Form.RecordSource = strSQL
Me.Table1_subform.Form.Requery
End Sub
Private Sub Form_Load()
AddMyTree
End Sub
__________________________________________
Can any body tell me what may be the problem ? I been struglling this for
days .
and
if possible can any one give me an example on how to make the treeview to be
displayed on a "year","Month","date" ,three levels grade, currently it just
displayed all the dates in the same manner
Many thanks !
the time
but for some of the computers. I used "date" as the node point for the
treeview,when click on a particular date , another subform will display
thecorresponding infor on this date. it works fine on my computer,HOWEVER,in
some other computers, it behavours like this:
1-7/8/2006- no disp, 8/8/2006-ok,9-12/8/2006-no dis, rest -ok
1-8/9/2006- no disp, 9/9/2006-ok,10-12/9/2006-no dis, rest -ok
1-9/10/2006- no disp, 10/10/2006-ok,11-12/10/2006-no dis, rest -ok
1-10/8/2006- no disp, 11/11/2006-ok,12/11/2006-no dis, rest -ok
Isn't it wierd ?!!! Here is my code:
___________________________________________
Sub AddMyTree()
On Error GoTo Err_AddMyTree
Dim conn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim nodCurrent As Node
Dim objTree As Object
Set objTree = Me.TreeView0
Set conn = CurrentProject.Connection
strSQL = "SELECT DISTINCT DateRec FROM Table1 GROUP BY DateRec"
rst.Open strSQL, conn, adOpenStatic, adLockReadOnly
Do While Not rst.EOF
Set nodCurrent = objTree.Nodes.Add(, , "a" & rst("DateRec"),
rst("DateRec"), 1, 2)
nodCurrent.Tag = rst("DateRec")
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Set conn = Nothing
Exit_AddMyTree:
Exit Sub
Err_AddMyTree:
Set rst = Nothing
Set conn = Nothing
MsgBox Err.Description, vbCritical, "AddMyTree"
Resume Exit_AddMyTree
End Sub
Private Sub Detail_Click()
End Sub
Private Sub TreeView0_NodeClick(ByVal Node As Object)
Dim strSQL As String
strSQL1 = "SELECT * FROM Table1 "
strSQL = strSQL1 & "WHERE DateRec = # " & CDate(Node.Tag) & " # "
Me.Table1_subform.Form.RecordSource = strSQL
Me.Table1_subform.Form.Requery
End Sub
Private Sub Form_Load()
AddMyTree
End Sub
__________________________________________
Can any body tell me what may be the problem ? I been struglling this for
days .
and
if possible can any one give me an example on how to make the treeview to be
displayed on a "year","Month","date" ,three levels grade, currently it just
displayed all the dates in the same manner
Many thanks !