The code below will load up the TreeView to display the following nodes...
RETURN TO ACCOUNT INVOICING
MENU OPTIONS
Find Client
Find Master Account
Find Transfer
2004
2005
2006
ARCHIVE
ABC Company
Invoice 1
Invoice 2
Invoice 3
Invoice 4
The code to display multiple companies & their invoices isn't too
difficult to understand, but a bit difficult for me to post here.
Sub loadTreeView_Archive(frmName As Form, lngAccountID As Long)
Dim accountHeaderNode As Node
frmName.ExplorerPane.Nodes.Clear
Set treeHeaderNode = frmName.ExplorerPane.Nodes.Add(, , , "Return
to Account Invoicing", "backArrow")
treeHeaderNode.Bold = True
treeHeaderNode.Key = "07MENU:BACK"
treeHeaderNode.Tag = "menuNode"
Call loadTreeView_Menu(frmName)
Set listHeader = frmName.ExplorerPane.Nodes.Add(, , , "Archive",
"archive")
listHeader.Key = "06N/A:NoAction"
listHeader.Tag = "noAction"
listHeader.Expanded = True
strAccountName = DLookup("txtMasterAccountCompanyName",
"tblMasterAccounts", "lngMasterAccountId = " & lngAccountID)
Set accountHeaderNode = frmName.ExplorerPane.Nodes.Add(listHeader,
tvwChild, , strAccountName, "AccountNode")
accountHeaderNode.Key = "09MASTER" & lngAccountID
accountHeaderNode.Expanded = True
Call loadInvoicesForAccount(frmName, lngAccountID, accountHeaderNode)
End Sub
Sub loadInvoicesForAccount(frmName As Form, lngAccountID As Long,
accountHeaderNode As Node)
'Get the SQL statement for the .OpenRecordSet method here
'Its pretty standard so not included in this newsgroup post
strSQL =
getAccountsToBeInvoicedBySQL("(tblMasterAccounts.lngMasterAccountID = "
& lngAccountID & ") AND tblInvoiceHeaders.txtStatus='Paid'")
Debug.Print strSQL
'Loop Through the Record Source and create 1 node for each Invoice
attached to the account
Set rsSource = CurrentDb.OpenRecordset(strSQL, dbOpenForwardOnly)
While Not rsSource.EOF
Set newInvoice =
frmName.ExplorerPane.Nodes.Add(accountHeaderNode, tvwChild, ,
rsSource!txtDescription, "InvoicePaid")
With newInvoice
.Key = "10INVOICE:" & rsSource!dblInvoiceBatchNumber
.Tag = "invoice"
End With
rsSource.MoveNext
Wend
End Sub
Sub loadTreeView_Menu(frmName As Form)
Set treeHeaderNode = frmName.ExplorerPane.Nodes.Add(, , , "Menu
Options", "listHeader")
treeHeaderNode.Key = "08NOACT:TREEHEADERNODE"
treeHeaderNode.Expanded = True
treeHeaderNode.Bold = True
'MARK - Added for CL Conversion
Set actionNode = frmName.ExplorerPane.Nodes.Add(treeHeaderNode,
tvwChild, , "Find Client", "find")
actionNode.Key = "07MENU:FindClientAccount"
actionNode.Tag = "menuNode"
'MARK - Added for CL Conversion
Set actionNode = frmName.ExplorerPane.Nodes.Add(treeHeaderNode,
tvwChild, , "Find Master Account", "find")
actionNode.Key = "07MENU:FindMasterAccount"
actionNode.Tag = "menuNode"
Set actionNode = frmName.ExplorerPane.Nodes.Add(treeHeaderNode,
tvwChild, , "Find Transfer", "find")
actionNode.Key = "08NOACT:FindTransport"
actionNode.Tag = "menuNode"
actionNode.Expanded = True
strSQL = ""
strSQL = strSQL & "SELECT DISTINCT DatePart('yyyy',[dteDate])
AS exprYear FROM tblTransports "
strSQL = strSQL & "ORDER BY DatePart('yyyy',[dteDate]);"
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenForwardOnly)
If rs.EOF = True Then
frmName.ExplorerPane.Nodes.Remove actionNode.Key
Else
While Not rs.EOF
Set childNode =
frmName.ExplorerPane.Nodes.Add(actionNode, tvwChild, , rs!exprYear & "
Transfers", "reservations")
childNode.Key = "07FIND:" & rs!exprYear
childNode.Tag = "menuNode"
rs.MoveNext
Wend
End If
Set rs = Nothing
End Sub