Results 1 to 2 of 2
  1. #1
    masoud_sedighy is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Dec 2011
    Posts
    78

    Active/visible sub form in the same location design dependent on node text

    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

  2. #2
    TG_W is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2010
    Location
    Manvel, TX
    Posts
    299
    If you have both subforms laying on top of each other in the main form, then you need to set one to visible and one not visible.

    Or

    You could have your VBA change the Source Object. Drag one of your subforms in and clear the source. Then depending on the text, you would change which subform is called using the code below.

    Code:
    me.YourBlankSubformNameHere.SourceObject = "Form.YourSubformNameHere"
    Me.Refresh

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Design help for item location and testing date database
    By asoe209 in forum Database Design
    Replies: 10
    Last Post: 06-20-2013, 12:13 PM
  2. In Query Design View fields in tables are not visible
    By s.j.hogerzeil in forum Queries
    Replies: 1
    Last Post: 06-09-2013, 10:31 AM
  3. Dyanmic location for transfer text
    By shanmugamgsn in forum Access
    Replies: 5
    Last Post: 07-17-2012, 11:30 PM
  4. Validation dependent Text
    By Arrrggggjhhhhh!!!! in forum Forms
    Replies: 3
    Last Post: 02-27-2012, 07:36 AM
  5. Replies: 2
    Last Post: 01-06-2011, 04:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums