Treeview-Change Branch Headings (1 Viewer)

nick.tait

Registered User.
Local time
Today, 12:43
Joined
May 25, 2009
Messages
16
Hi everyone
I have written this code which produces a tree (see attachment). Basically i want all of the information put into a previous branch called assetnumber. When u click on assetnumber i would like the attached view to come up. so really i just want another branch containing the info i hve already got. can anyone help me out?? the code is below. Thanks in advance

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rs2 As DAO.Recordset
Dim strQuery1 As String
Dim strQuery2 As String

Dim nod As Object
Dim strNode1Text As String
Dim strNode2Text As String
Dim strVisibleText As String
Dim strMessage As String
Dim intVBMsg As Integer
Dim intCounter As Integer
Dim stringcount As String

intCounter = 1
Set db = CurrentDb()
strQuery1 = "select DISTINCT AssetNumber from [Asset Master]"
With Me![Custodian History Form]
Set rs = db.OpenRecordset(strQuery1) ', dbOpenForwardOnly)
Do Until rs.EOF
Debug.Print rs![Assetnumber]
strNode1Text = StrConv("Level1" & rs![Assetnumber], _
vbLowerCase)
Set nod = .Nodes.Add(Key:=strNode1Text, Text:=rs![Assetnumber])
nod.Expanded = False

strQuery2 = "select DISTINCT AssetNumber, [Asset Name] from [Asset Master] where [AssetNumber] = " & nod.Text
Set rs2 = db.OpenRecordset(strQuery2)
Do Until rs2.EOF
strNode2Text = StrConv("Level2" & rs2![Asset Name], vbLowerCase)
strVisibleText = rs2!Assetnumber
'if modelname is null, will have problem
If IsNull(rs2!Assetnumber) Then
MsgBox "number is null"
strVisibleText = "No Name"
End If
stringcount = CStr(intCounter)
strNode2Text = strNode2Text + stringcount
Set nod = .Nodes.Add(relative:=strNode1Text, relationship:=tvwChild, _
Key:=strNode2Text, Text:=strVisibleText)
rs2.MoveNext
Loop
rs2.Close
rs.MoveNext
Loop
rs.Close
End With
End Sub
 

nick.tait

Registered User.
Local time
Today, 12:43
Joined
May 25, 2009
Messages
16
i didnt. there are different problems or the older one has been fixed
 

Users who are viewing this thread

Top Bottom