Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2009
    Posts
    204

    Unanswered: Expandlble selection, similar to Windows Explorer

    I am trying to make an expandable page. My current methodology is 2 buttons overlapping each other, one with a pplus sign and one with a minus sign. When one is clicked, the other becomes visible, shows the caption, and moves every other title and button. The propblem that I am foreseeing now, is this is very cumbersome and will take me forever to code all of this, because if I have one expanded, and try to expand another one, it won't work right.....Here is the code I am working with so far, and I have only scratched the surface. Does anyone know of any easier way at all?

    Code:
    Private Sub Form_Current()
    Me.Label0caption.Visible = False
    Me.label0_hyperlink.Visible = False
    Me.label0_collapse.Visible = False
    Me.Label1caption.Visible = False
    Me.Label1_hyperlink.Visible = False
    Me.label1_collapse.Visible = False
    Me.Label2caption.Visible = False
    Me.label2_collapse.Visible = False
    Me.Label3caption.Visible = False
    Me.label3_collapse.Visible = False
    Me.Label4caption.Visible = False
    Me.label4_collapse.Visible = False
    Me.Label5caption.Visible = False
    Me.label5_collapse.Visible = False
    Me.Label5_hyperlink1.Visible = False
    Me.Label5_hyperlink2.Visible = False
    Me.label6_collapse.Visible = False
    Me.Label0title.Top = 0.375 * 1440
    Me.Label0caption.Top = 0.5833 * 1440
    Me.label0_collapse.Top = 0.375 * 1440
    Me.label0_expand.Top = 0.375 * 1440
    Me.label0_hyperlink.Top = 1.5 * 1440
    Me.Label1title.Top = 0.6667 * 1440
    Me.label1_expand.Top = 0.6667 * 1440
    Me.Label2title.Top = 0.9583 * 1440
    Me.label2_expand.Top = 0.9583 * 1440
    Me.Label3title.Top = 1.25 * 1440
    Me.label3_expand.Top = 1.25 * 1440
    Me.Label4title.Top = 1.5417 * 1440
    Me.label4_expand.Top = 1.5417 * 1440
    Me.Label5title.Top = 1.8333 * 1440
    Me.label5_expand.Top = 1.8333 * 1440
    Me.Label6title.Top = 2.125 * 1440
    Me.label6_expand.Top = 2.125 * 1440
    
    End Sub
    
    Private Sub label0_collapse_Click()
    
    
    Me.Label0caption.Visible = False
    Me.label0_hyperlink.Visible = False
    Me.label0_expand.Visible = True
    Me.label0_expand.SetFocus
    Me.label0_collapse.Visible = False
    Me.Label0title.Top = 0.375 * 1440
    Me.label0_expand.Top = 0.375 * 1440
    Me.Label1title.Top = 0.6667 * 1440
    Me.label1_expand.Top = 0.6667 * 1440
    Me.Label2title.Top = 0.9583 * 1440
    Me.label2_expand.Top = 0.9583 * 1440
    Me.Label3title.Top = 1.25 * 1440
    Me.label3_expand.Top = 1.25 * 1440
    Me.Label4title.Top = 1.5417 * 1440
    Me.label4_expand.Top = 1.5417 * 1440
    Me.Label5title.Top = 1.8333 * 1440
    Me.label5_expand.Top = 1.8333 * 1440
    Me.Label6title.Top = 2.125 * 1440
    Me.label6_expand.Top = 2.125 * 1440
    End Sub
    
    Private Sub label0_expand_Click()
    
    
    Me.Label0caption.Visible = True
    Me.label0_hyperlink.Visible = True
    Me.label0_collapse.Visible = True
    Me.label0_collapse.SetFocus
    Me.label0_expand.Visible = False
    Me.Label1title.Top = 1.7083 * 1440
    Me.label1_expand.Top = 1.7083 * 1440
    Me.Label2title.Top = 2 * 1440
    Me.label2_expand.Top = 2 * 1440
    Me.Label3title.Top = 2.2917 * 1440
    Me.label3_expand.Top = 2.2917 * 1440
    Me.Label4title.Top = 2.5833 * 1440
    Me.label4_expand.Top = 2.5833 * 1440
    Me.Label5title.Top = 2.875 * 1440
    Me.label5_expand.Top = 2.875 * 1440
    Me.Label6title.Top = 3.1667 * 1440
    Me.label6_expand.Top = 3.1667 * 1440
    End Sub
    
    Private Sub label1_collapse_Click()
    
    If Me.Label0caption.Visible = True Then
        Me.Label1title.Top = 1.7083 * 1440
        Me.label1_expand.Top = 1.7083 * 1440
        Me.Label2title.Top = 2 * 1440
        Me.label2_expand.Top = 2 * 1440
        Me.Label3title.Top = 2.2917 * 1440
        Me.label3_expand.Top = 2.2917 * 1440
        Me.Label4title.Top = 2.5833 * 1440
        Me.label4_expand.Top = 2.5833 * 1440
        Me.Label5title.Top = 2.875 * 1440
        Me.label5_expand.Top = 2.875 * 1440
        Me.Label6title.Top = 3.1667 * 1440
        Me.label6_expand.Top = 3.1667 * 1440
        Me.Label1caption.Visible = False
        Me.Label1_hyperlink.Visible = False
        Me.label1_expand.Visible = True
        Me.label1_expand.SetFocus
        Me.label1_collapse.Visible = False
    Else
        Me.Label0title.Top = 0.375 * 1440
        Me.Label0caption.Top = 0.5833 * 1440
        Me.label0_collapse.Top = 0.375 * 1440
        Me.label0_expand.Top = 0.375 * 1440
        Me.label0_hyperlink.Top = 1.5 * 1440
        Me.Label1title.Top = 0.6667 * 1440
        Me.label1_expand.Top = 0.6667 * 1440
        Me.Label2title.Top = 0.9583 * 1440
        Me.label2_expand.Top = 0.9583 * 1440
        Me.Label3title.Top = 1.25 * 1440
        Me.label3_expand.Top = 1.25 * 1440
        Me.Label4title.Top = 1.5417 * 1440
        Me.label4_expand.Top = 1.5417 * 1440
        Me.Label5title.Top = 1.8333 * 1440
        Me.label5_expand.Top = 1.8333 * 1440
        Me.Label6title.Top = 2.125 * 1440
        Me.label6_expand.Top = 2.125 * 1440
        Me.Label1caption.Visible = False
        Me.Label1_hyperlink.Visible = False
        Me.label1_expand.Visible = True
        Me.label1_expand.SetFocus
        Me.label1_collapse.Visible = False
    End If
    
    End Sub
    
    Private Sub label1_expand_Click()
    
    If Me.Label0caption.Visible = True Then
        Me.Label0title.Top = 0.375 * 1440
        Me.Label0caption.Top = 0.5833 * 1440
        Me.label0_collapse.Top = 0.375 * 1440
        Me.label0_expand.Top = 0.375 * 1440
        Me.label0_hyperlink.Top = 1.5 * 1440
        Me.Label1title.Top = 1.7083 * 1440
        Me.Label1caption.Top = 1.9167 * 1440
        Me.label1_collapse.Top = 1.7083 * 1440
        Me.label1_expand.Top = 1.7083 * 1440
        Me.Label1_hyperlink.Top = 1.9167 * 1440
        Me.Label2title.Top = 2.125 * 1440
        Me.label2_expand.Top = 2.125 * 1440
        Me.Label3title.Top = 2.4167 * 1440
        Me.label3_expand.Top = 2.4167 * 1440
        Me.Label4title.Top = 2.7083 * 1440
        Me.label4_expand.Top = 2.7083 * 1440
        Me.Label5title.Top = 3 * 1440
        Me.label5_expand.Top = 3 * 1440
        Me.Label6title.Top = 3.2917 * 1440
        Me.label6_expand.Top = 3.2917 * 1440
        Me.Label1caption.Visible = True
        Me.Label1_hyperlink.Visible = True
        Me.label1_collapse.Visible = True
        Me.label1_collapse.SetFocus
        Me.label1_expand.Visible = False
    Else
        Me.Label0title.Top = 0.375 * 1440
        Me.label0_expand.Top = 0.375 * 1440
        Me.Label1title.Top = 0.6667 * 1440
        Me.Label1caption.Top = 0.875 * 1440
        Me.label1_collapse.Top = 0.6667 * 1440
        Me.label1_expand.Top = 0.6667 * 1440
        Me.Label1_hyperlink.Top = 0.875 * 1440
        Me.Label2title.Top = 1.0833 * 1440
        Me.label2_expand.Top = 1.0833 * 1440
        Me.Label3title.Top = 1.375 * 1440
        Me.label3_expand.Top = 1.375 * 1440
        Me.Label4title.Top = 1.6667 * 1440
        Me.label4_expand.Top = 1.6667 * 1440
        Me.Label5title.Top = 1.9583 * 1440
        Me.label5_expand.Top = 1.9583 * 1440
        Me.Label6title.Top = 2.25 * 1440
        Me.label6_expand.Top = 2.25 * 1440
        Me.Label1caption.Visible = True
        Me.Label1_hyperlink.Visible = True
        Me.label1_collapse.Visible = True
        Me.label1_collapse.SetFocus
        Me.label1_expand.Visible = False
    End If
    End Sub

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    What you are trying to duplicate is the Microsoft Tree View Control. I have never used it in Access but I just added one to a form using the Insert/ActiveX Control menu option. You will probably have to search the web for programming examples. Unless someone else is able to help out.

  3. #3
    Join Date
    Oct 2009
    Posts
    204
    Quote Originally Posted by DCKunkle View Post
    What you are trying to duplicate is the Microsoft Tree View Control. I have never used it in Access but I just added one to a form using the Insert/ActiveX Control menu option. You will probably have to search the web for programming examples. Unless someone else is able to help out.
    Thank you but doing that is way beyond my abilities. I ended up using hyperlinks to separate forms instead of a collapsable menu, which is not what I wanted, but it looks very clean on the user's end.

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I'm not sure if this applies to your situation but I will often utilize the .caption part of the label.

    ie. somevariable = me.MyLabelName.caption
    and then continue from there in my code.

    or you can use code such as:
    For X = 1 to 13 'or whatever range
    me.label1(" & X & ").visible = true.........or maybe its: me.label1("X").visible = true - can't recall offhand
    next X

    This makes it easy to cycle through all the labels but you need to make sure the numbering in the labels' name is setup correctly.
    Last edited by pkstormy; 11-27-09 at 04:00.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •