Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    benjammin is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Nov 2010
    Posts
    60

    form with expanding/shrinking sub-forms?

    Hi,



    Attached is a poorly done mock up of what I'm looking for but I think you'll get the idea. A user will select a site and station, possibly a location and will populate the subforms (each calibration, water level, etc.. is a separate table) and you can click on the plus box to expand it and see what calibrations there are for that station. How can I do these grow/shrink boxes?

    Thank you

    Click image for larger version. 

Name:	wanted.png 
Views:	33 
Size:	86.5 KB 
ID:	13421

  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,624
    Forms don't behave that way. That's why they have scroll bars.

    How would you know what is big enough? At some point the number of records will exceed capacity of screen to display all.
    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
    benjammin is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Nov 2010
    Posts
    60
    Well, it's basically a subform within a form that can be collapsed. The subform is a fixed size so you have scroll bars if the data exceeds the size of the subform. I think I've figured it out and will post what I have when I'm finished.

  4. #4
    benjammin is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Nov 2010
    Posts
    60
    Code:
    Private Sub cmdFlowShutter_Click()    Dim spaceBetween As Integer, origTop As Integer
        
        If cmdFlowShutter.Caption = "-" Then
            cmdFlowShutter.SetFocus
            frmSubFlow.Visible = False
            spaceBetween = lblWL.Top - frmSubFlow.Top - frmSubFlow.Height
            origTop = lblWL.Top
            lblWL.Top = lblFlow.Top + lblFlow.Height + spaceBetween
            cmdWLShutter.Top = cmdWLShutter.Top - (origTop - lblWL.Top)
            boxWL.Top = boxWL.Top - (origTop - lblWL.Top)
            frmSubWL.Top = lblWL.Top + lblWL.Height     ' Or frmSubWL.top = frmSubWL.top - (origtop - lblWL.top) (not tried but should work)
            cmdFlowShutter.Caption = "+"
        Else
            spaceBetween = lblWL.Top - lblFlow.Top - lblFlow.Height
            origTop = lblWL.Top
            lblWL.Top = frmSubFlow.Top + frmSubFlow.Height + spaceBetween
            cmdWLShutter.Top = cmdWLShutter.Top + (lblWL.Top - origTop)
            boxWL.Top = boxWL.Top + (lblWL.Top - origTop)
            frmSubWL.Top = lblWL.Top + lblWL.Height
            
            frmSubFlow.Visible = True
            cmdFlowShutter.SetFocus  ' Maybe setfocus to the Flow id or comment or other field in Flow subform.
            cmdFlowShutter.Caption = "-"
        End If
    End Sub
    
    
    
    
    Private Sub cmdWLShutter_Click()
        If cmdWLShutter.Caption = "-" Then
            cmdWLShutter.SetFocus
            frmSubWL.Visible = False
            cmdWLShutter.Caption = "+"
        Else
            frmSubWL.Visible = True
            cmdWLShutter.SetFocus  ' Maybe setfocus to the WL id or comment or other field in WL subform.
            cmdWLShutter.Caption = "-"
        End If
    End Sub
    
    
    
    
    Private Sub cmdCondShutter_Click()
        If cmdCondShutter.Caption = "-" Then
            cmdCondShutter.SetFocus
            frmSubCond.Visible = False
            cmdCondShutter.Caption = "+"
        Else
            frmSubCond.Visible = True
            cmdCondShutter.SetFocus  ' Maybe setfocus to the WL id or comment or other field in WL subform.
            cmdCondShutter.Caption = "-"
        End If
    End Sub
    This works great for TWO sub-forms but once I add more everything breaks down due to the difference between the spacing of the top collapsed form and the furthest down gets whacky and since I have ~6 sub-forms I want to add, this won't really scale properly. I'm not very good at VBA to create a function that might better do this. Should I just scrap expanding/collapsing sub-forms? I just like that you can pull all the different data for a station and display it at once which allows you to compare calibration times...

    Click image for larger version. 

Name:	ss.png 
Views:	27 
Size:	106.9 KB 
ID:	13437

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Consider putting the subforms on pages of 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.

  6. #6
    benjammin is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Nov 2010
    Posts
    60
    Well that works out fairly well, thanks for the suggestion. Still kinda bummed about not being able to line them up like I wanted but until a user says otherwise this will work.

  7. #7
    faythe1215 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    52
    I hate to bump an old thread, but just for the sake of clarification - subforms cannot auto grow and shrink, correct?

  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,624
    AFAIK, that's why they have vertical scroll bar.

    Subreports, however, do grow and shrink.
    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
    sh3p is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    7
    Subforms can grow and shrink - I am looking at one I built. In order for the subform to grow and shrink with a resizable window it must be anchored to the left and right sides or top and bottom depending on how you want it to grow (horizontally/vertically). Use the horizontal anchor and vertical anchor attributes and set one to both, then resize your window and see what happens.

  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,624
    Okay, learning something new, however, I don't really like the effect.
    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
    sh3p is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    7
    Agreed...and when you have a complex form it can be quite painful to get things working right.

  12. #12
    faythe1215 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    52
    Quote Originally Posted by sh3p View Post
    Subforms can grow and shrink - I am looking at one I built. In order for the subform to grow and shrink with a resizable window it must be anchored to the left and right sides or top and bottom depending on how you want it to grow (horizontally/vertically). Use the horizontal anchor and vertical anchor attributes and set one to both, then resize your window and see what happens.
    This didn't work for me. Did I miss something?
    Attachment 19545Attachment 19546

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    You are using Tabbed Documents, try setting the db for Overlapping Windows.

    If you want the subform to grow vertically, then set the Vertical Anchor to Both.

    Also, you appear to have a textbox on the main form below the subform. I tested similar arrangement and when the subform grows it covers the textbox. I don't know why your subform is behind the textbox.
    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.

  14. #14
    faythe1215 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    52
    I made the adjustments you suggested, and aside from the overlapping window view, it has made no difference in the appearance of the form.

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Would have to examine your db. If you want to provide, follow instructions at bottom of my post.
    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.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Expanding sections
    By Count Duckula in forum Reports
    Replies: 2
    Last Post: 06-13-2013, 11:36 PM
  2. Date expanding?
    By tylerg11 in forum Access
    Replies: 1
    Last Post: 03-04-2013, 03:34 PM
  3. expanding access database
    By sloppyjoe778 in forum Access
    Replies: 8
    Last Post: 12-12-2011, 12:13 AM
  4. Expanding a form's data fields
    By hertfordkc in forum Forms
    Replies: 6
    Last Post: 07-18-2011, 12:33 PM
  5. Expanding Memo Field in Form
    By AKQTS in forum Forms
    Replies: 3
    Last Post: 07-26-2010, 08:51 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