Results 1 to 12 of 12
  1. #1
    bytreeide is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    47

    Expandable and Collapsible 'Headings' for forms [Access 2010]

    I am creating a form that will have some fields that may or may not be used in all cases.

    This form ends up being quite long, so I am wondering if there is any way that I can "collapse" sections of the form similar to the way that MS Word can do that with the Headings.

    So I want to have several headings in the form of "+/-" boxes or check-boxes that I can click, that would expand the sections below them in order to fill in the fields included in such a section.

    Example:

    Before:
    [+] Heading 1


    [+] Heading 2
    [+] Heading 3

    After clicking on the "+" for headings 1 and 3:
    [-] Heading 1
    Field 1.1
    Field 1.2
    Field 1.3
    [+] Heading 2
    [-] Heading 3
    Field 3.1
    Field 3.2
    Field 3.3

    Can this be done?
    If so, how do I do it?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What do you mean by 'several headings' - how is this accomplished?

    Could use a Tab control to organize data.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    bytreeide is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    47
    Quote Originally Posted by June7 View Post
    What do you mean by 'several headings' - how is this accomplished?
    The number of headings is irrelevant, more than one. At the moment this isn't accomplished, I am desiring to find out how to accomplish this feat. These "headings" that I have are just check boxes that cause all of the fields under that heading to be visible and then not visible.

    Quote Originally Posted by June7 View Post
    Could use a Tab control to organize data.
    I have to be honest and say that I really don't know what you mean by this, probably because I still have a lot of learning to do on Access. I already have several forms that are organized with a navigation form that has tabs. Each of these forms has topic specific data that I want to keep together in one place. Or do you mean to make a subform that has tabs that could contain these "headings"?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I don't like and don't use navigation form.

    I do use a Tab control to organize lots of data. Research it, you might like it.

    Does not mean a subform is necessary but subforms can be placed on a Tab control.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    bytreeide is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    47
    I will look into it, however I don't consider this issue resolved yet.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Back to your question about 'collapsing' multiple form header sections - No, not a feature in Access. There is only one each of form header, footer, detail, page sections. Your checkboxes with code that hides/unhides controls is one approach, organizing controls onto a Tab control is another.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    bytreeide is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    47
    I wasn't referring to "headers/footers" but to "Headings" like section-headings. I was wondering if Access contained the same ability that Word does, with the ability to show and hide all of the text under one of the section-headings. I think this might be a new feature as of Office 2013.

    I have gotten the tab control to work and thus far I like how it works, it fits the need that I had.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Can hide the entire section. There are no 'headings' to hide.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    bytreeide is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    47
    I am aware that there are no "Headings" in Access, I think you are mis-understanding me. I want Access to be able to mimic what Word can do, via VBA or Macro. So I am using terms from Word (like heading), because that is something that I understand. I am trying to find commonality... Do you know what I am talking about when referring to "Headings" in MS Word?

    What exactly do you mean by "...hide the entire section."?

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Hide Header, Footer, Page, Detail section. (Actually, Page section can display only when form is printed - printing form is rarely done.)

    Believe I do understand. Apparently is an Add-in for Word 2007/2010. You are mimicking in Access form with the +/- checkboxes. Alternatives are Tab control or Navigation form.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,928
    it can be done. I don't have to code available but basically you need to use the controls top, height, tag and visible properties

    basic rules

    1. headings are always visible
    2. each control needs to know the name of the control below it (suggest use the tag property)
    3. the top of the next control is calculated from the top of the previous visible control plus the height of the previous visible control plus a bit
    4. headings need to 'know' if it's detail section is visible or not
    5. headings need to be identifiable as headings (suggest put a - before the next control name in the tag e.g. -txtcontrol


    the code starts from the heading 'clicked' and moves on to each control in turn, within its section, setting the visible property and top property if required and for following sections the top property only

    a 'redraw' sub would look something like

    dim ctrl as control
    dim ctrltop as single
    ctrl=screen.activecontrol
    ctrltop=ctrl.top
    if me(mid(ctrl.tag,1)).visible=true then 'section is visible, so hide it
    me(mid(ctrl.tag,1)).visible=false
    ctrl=me(ctrl.tag)
    while left(ctrl.tag,1)<>"-"
    me(mid(ctrl.tag,1)).visible=false
    ctrl=me(ctrl.tag)
    wend
    else 'open it
    me(mid(ctrl.tag,1)).visible=true
    me(mid(ctrl.tag,1)).top=ctrl.top+ctrl.height+60
    ctrl=me(ctrl.tag)
    while left(ctrl.tag,1)<>"-"
    me(mid(ctrl.tag,1)).visible=true
    me(mid(ctrl.tag,1)).top=ctrl.top+ctrl.height+60
    wend

  12. #12
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,928
    sorry - thread updated before I finished

    a 'redraw' sub would look something like

    Code:
    Private sub reDraw()
    Dim ctrl as control
     dim ctrltop as single
     ctrl=screen.activecontrol
     ctrltop=ctrl.top+ctrl.height+60
     if me(mid(ctrl.tag,1)).visible=true then 'section is visible, so hide it
        me(mid(ctrl.tag,1)).visible=false
        ctrl=me(ctrl.tag)
        while left(ctrl.tag,1)<>"-"
            me(mid(ctrl.tag,1)).visible=false
            ctrl=me(ctrl.tag)
        wend
     else 'open it
        me(mid(ctrl.tag,1)).top=ctrltop
        me(mid(ctrl.tag,1)).visible=true
        ctrl=me(ctrl.tag)
        ctrltop=ctrltop+ctrl.height+60
        While left(ctrl.tag,1)<>"-" or ctrl.tag<>""
            me(ctrl.tag).top=ctrltop
            me(ctrl.tag).visible=true
            ctrl=me(ctrl.tag)
            ctrltop=ctrltop+ctrl.height+60
        wend
    
    'Adjust tops of remaining controls
    While ctrl.tag<>""
        if ctrl.visible=true
            me(ctrl.tag).top=ctrltop
            me(ctrl.tag).visible=true
            ctrl=me(ctrl.tag)
            ctrltop=ctrltop+ctrl.height+60
       end if
    wend
    
    end sub
    this does not contain error code has not been tested but created from memory and will need to be adjusted to account for controls that are aligned horizontally

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

Similar Threads

  1. Replies: 3
    Last Post: 02-26-2014, 03:21 PM
  2. Replies: 3
    Last Post: 10-31-2013, 02:36 PM
  3. Replies: 3
    Last Post: 10-23-2013, 08:11 AM
  4. Forms in Access 2010
    By GaryLW in forum Forms
    Replies: 3
    Last Post: 03-22-2013, 07:11 PM
  5. Access 2010 Sub forms
    By jordanturner in forum Access
    Replies: 1
    Last Post: 10-06-2010, 06:55 PM

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