同一个TREEVIEW的过程如何供不同的窗体调用,可不可以让窗体名称做为变量
这是一个TREEVIEW过程,因为我这个过程可能被几个窗体调用,就是窗体名称不同,其余都相同,如果把'main_jczl_depa.TreeView1.Nodes.Clear前面的main_jczl_depa.去除,则在运行时提示需要对象,但如果我对每一个窗体都做一个TREEVIEW过程好象就哆嗦了。
Public Function TREE_CHANGEdepa()
'main_jczl_depa.TreeView1.Nodes.Clear
TreeView1.Nodes.Clear
RS6.Open "select FITEMID,FSHORTNUMBER+'('+FNAME+')' AS fNAME,FPARENTID,FITEMCLASSID from depa ", Cnn, adOpenForwardOnly, adLockOptimistic, -1
RS7.Open "select count(*) from depa ", Cnn, adOpenForwardOnly, adLockOptimistic, -1
Dim I As Integer, K As Integer
K = RS7.Fields(0)
'main_jczl_depa.TreeView1.Nodes.Add , , "K_0", "部门基本信息", Image:="close"
TreeView1.Nodes.Add , , "K_0", "部门基本信息", Image:="close"
For I = 1 To K
If I <= K Then
'main_jczl_depa.TreeView1.Nodes.Add RELATIVE:="K_" & RS6.Fields("FPARENTID").Value, RELATIONSHIP:=tvwChild, Key:="K_" & RS6.Fields("FITEMID").Value, text:=RS6.Fields("fName").Value, Image:="close"
TreeView1.Nodes.Add RELATIVE:="K_" & RS6.Fields("FPARENTID").Value, RELATIONSHIP:=tvwChild, Key:="K_" & RS6.Fields("FITEMID").Value, text:=RS6.Fields("fName").Value, Image:="close"
End If
RS6.MoveNext
Next I
RS6.Close
Set RS6 = Nothing
Set RS7 = Nothing
End Function