silentwolf
Well-known Member
- Joined
- May 14, 2008
- Messages
- 1,216
- Office Version
- 2016
Hi guys,
Just wondering if someone can tell me what I do wrong with my treeview control.
Situation:
I have a treeview control (tvwKundenRechnung) two textboxes txtKunden and txtRechnung two subforms subfrmKunde and subfrmRechnung.
CustomerId is the parent node of my treeview control. And the Invoices (Rechnungen) is the child.
When I select the invoice number the value (Rech_id) gets displayed in txtRechnung and that textbox is linked with my subfrmRechnung to show all relevant Information about the Rechnung (Invoice). That works fine!
But the problem is when I select the CustomerId in my txtKunde there is enName=101 displayed rather then only the customerId so "101"
That means that the subfrmCustomer gets displayed but with all empty fields ,
When I do write in the txtKunden the number 101 then the subfrmKunden displayes all relevant customer Information.
So I am wondering what the problem is and how I could fix it?
Here is the code I use and maybe someone could take a look at it for me please.
Would be nice if someone knows what am I doing wrong here.
Many thanks
Albert
Just wondering if someone can tell me what I do wrong with my treeview control.
Situation:
I have a treeview control (tvwKundenRechnung) two textboxes txtKunden and txtRechnung two subforms subfrmKunde and subfrmRechnung.
CustomerId is the parent node of my treeview control. And the Invoices (Rechnungen) is the child.
When I select the invoice number the value (Rech_id) gets displayed in txtRechnung and that textbox is linked with my subfrmRechnung to show all relevant Information about the Rechnung (Invoice). That works fine!
But the problem is when I select the CustomerId in my txtKunde there is enName=101 displayed rather then only the customerId so "101"
That means that the subfrmCustomer gets displayed but with all empty fields ,
When I do write in the txtKunden the number 101 then the subfrmKunden displayes all relevant customer Information.
So I am wondering what the problem is and how I could fix it?
Here is the code I use and maybe someone could take a look at it for me please.
Code:
Private Sub CreateCustomerNodes()
Dim rst As DAO.Recordset ' recordset for category data
' open the recordset for categories
Set rst = CurrentDb.TableDefs!tblKunde.OpenRecordset
' loop through the rows in the recordset
rst.MoveFirst
Do Until rst.EOF
With Me.tvwKundenRechnung.Nodes.Add(Text:=rst!Kun_id, _
Key:="FirmenName=" & CStr(rst!Kun_id))
.Expanded = True
End With
rst.MoveNext
Loop
' rst.Close
' Set rst = Nothing
End Sub
Private Sub CreateBillNodes()
Dim rst As DAO.Recordset ' recordset for product data
' open the recordset for products
Set rst = CurrentDb.TableDefs!tblRechnung.OpenRecordset
' loop through the rows in the recordset
rst.MoveFirst
Do Until rst.EOF
Me.tvwKundenRechnung.Nodes.Add Relationship:=tvwChild, _
Relative:="FirmenName=" & CStr(rst!Kun_id_f), _
Text:=rst!RechNummer, Key:="Rech=" & CStr(rst!Rech_id)
rst.MoveNext
Loop
' rst.Close
' Set rst = Nothing
End Sub
Private Sub cmdCollapseAll_Click()
Dim nodthis As MSComctlLib.Node
For Each nodthis In Me.tvwKundenRechnung.Nodes ' loop through all nodes
nodthis.Expanded = False
Next nodthis
Me.tvwKundenRechnung.SetFocus
End Sub
Private Sub cmdExpandAll_Click()
Dim nodthis As MSComctlLib.Node
For Each nodthis In Me.tvwKundenRechnung.Nodes ' loop through all nodes
nodthis.Expanded = True
Next nodthis
With Me.tvwKundenRechnung
.SetFocus ' move focus back to the treeview
' make sure the selected item is back into the visible part of the treeview
.SelectedItem.EnsureVisible
End With
End Sub
Private Sub Form_Open(Cancel As Integer)
SetupTreeview
CreateCustomerNodes
CreateBillNodes
End Sub
Private Sub SetupTreeview()
With Me.tvwKundenRechnung
.Style = tvwTreelinesPlusMinusText
.LineStyle = tvwRootLines
.Indentation = 240
.Appearance = ccFlat
.HideSelection = False
.BorderStyle = ccFixedSingle
.HotTracking = True
.FullRowSelect = True
.Checkboxes = False
.SingleSel = False
.Sorted = False
.Scroll = True
.LabelEdit = tvwManual
.Font.Name = "Verdana"
.Font.Size = 9
End With
End Sub
Private Sub tvwKundenRechnung_Click()
Dim nodSelected As MSComctlLib.Node ' a variable for the currently selected node
Set nodSelected = Me.tvwKundenRechnung.SelectedItem ' get the currently selected node
If nodSelected.Key Like "Rech=*" Then ' are we on a bill node
Me.txtRechnung = Mid(nodSelected.Key, 6)
Me.subfrmRechnung.Visible = True
Me.txtKunden = Null
Me.subfrmKunde.Visible = False
ElseIf nodSelected.Key Like "FirmenName=*" Then ' are we on a customer node
Me.txtKunden = Mid(nodSelected.Key, 5)
Me.subfrmKunde.Visible = True
Me.txtRechnung = Null
Me.subfrmRechnung.Visible = False
Else ' somehow this is neither a customer or bill node
Me.txtRechnung = Null
Me.subfrmRechnung.Visible = False
Me.txtKunden = Null
Me.subfrmKunde.Visible = False
End If
End Sub
Many thanks
Albert