In my main form there is a tree view and I like depending on node click, subform1 or subform2 will be active / visible in the same location design.
In the subform1 I have a list box "ItemList" that shows list of items from tblItems.
In the subform2 I have a list box "tasklist" that shows list of tasks from tbltasks.
Now in the treeview after root node I have 2 subnode
Text of subnode1 is "items"
Text of subnode2 is "tasks"
Now I like when click on tree view node "items" subform1 "fsubItems" will be visible beside tree view and " fsubtask " automatically will be invisible/inactive.
And when click on tree view node "tasks" subform2 "fsubtask" will be visible beside tree view and "fsubitems" automatically will be invisible / inactive.
Before when I had just a subform "fsubitems" I was using below code and it was working, now for dependent subfom I do not know how I have to design main form (putting 2 subform in main form) and how to code treeview for that.
Private Sub TreeView_NodeClick(ByVal selectedNode As Object)
On Error GoTo Error_Trap
Dim frm As Access.Form
Dim strNodeText As String
Dim strTitlePlus As String
Set frm = Me![fsubItem].Form
'MsgBox selectedNode.Text
' MsgBox selectedNode.Key
If Len(selectedNode.Key) >= 4 Then
strNodeText = selectedNode.Text
Me![txtSelectedDoc].Value = strNodeText
frm.Requery
frm.ItemList.Requery
frm.Visible = True
Else
frm.Visible = False
End If
Error_Exit:
Exit Sub
Error_Trap:
MsgBox ("Error Code:" & Err.Number & " Error Description:" & Err.Description)
Resume Error_Exit
End Sub