Results 1 to 10 of 10
  1. #1
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239

    Resizing master form when subform resizes

    Hi,

    I have code that dynamically resizes subforms according to records in It, and moves all controls above/below subforms.

    Now I want to resize master form too, when records are added or deleted in subforms, dynamically.



    What I've been trying so far is to set .InsideHeight of master form to .Top property of last control below subform (near footer of form).

    Code works, but only with control's .Top property in design view. That's no use to me, since all controls are moved dynamically according to subform records, so controls move after Load_event. There are other issues with code too.

    Code:
    Me.InsideHeight = [Combo1].Top + [Combo1].Height + 100
    How can I make this working ?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why bother with this? This is why forms have scroll bars. Could there be so many records that the form sizes could exceed screen space?

    If control's Top property can only be grabbed during Design View, that's the way it is. What else could you use to determine form size?
    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
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    Why bother with this? This is why forms have scroll bars. Could there be so many records that the form sizes could exceed screen space?
    It's just a desired visual effect, scroll bars are not what I would like. So you think this can't be done other way?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Seems to me would be a rather annoying visual effect. Not something I would ever do. Maybe the height of the subform could be grabbed and used to calculate main form height.
    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
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    It isn't anoying visual effect. I have 6 subforms that change their .InsideHeight according to their records. When all of them have about 3-4 records entered is master form very "filled" and user can't see all data, due to small form size.

    However, If there are no records in subforms (like blank master record), and I design size of form so that It will fit all 3-4 records for each subform,...then form is very big and strange, since there is a lot of blank area.

  6. #6
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    Here, look at this sample :

    open TblName, there you'll see combobox for field "Surname" - this is a subform. Select another value from combobox in blank combo under "Deere", and then another value. You'll notice that control under subform is moving, but when It reaches bottom of form....take a look !

    Now imagine that I have many subforms like this on same form, so size of form is drastically changing according to specific records.


    EDIT: Sorry, change form size "TblName" to smaller, now It' s too big. Change It so that control under will be almost at bottom of form.
    Attached Files Attached Files

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Okay, see it, don't like it.

    Seems to me could add so many records the form could get too large for screen display.

    Your code still uses the Top property. Since we know that doesn't work, have you tried suggestion for using subform Height to calculate revised form size?

    Another poster seems to be having similar issue https://www.accessforums.net/forms/s...7-a-57004.html
    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.

  8. #8
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    to resize a main form, use the me.move function to set its size and postion relative to the access window

    https://msdn.microsoft.com/en-us/lib.../ff845906.aspx

  9. #9
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    thanks for responses.

    Not sure I can use any of your suggestions, at least not in easy way. My solution does not contain only one subform in form, but about seven....

    So I need something that will resize form whenever a record is added/deleted in those subforms. I'm thinking about .Form.Move method based on each subform .insideheight, but can't figure how to create Loop for all subforms at once.

  10. #10
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    found solution

    Just had to resize form .InsideHeight in Activate_event:

    Code:
    Private Sub Form_Activate()
    Forms![TblName].InsideHeight = Forms![TblName]![TblJoin].Top + Forms![TblName]![TblJoin].Form.InsideHeight + 2300
    Call Refresh_Subform
    End Sub
    However, haven't tested fully in my DB, so I reckon there will be some issues when navigating records, and I will need a lot of coding for each subform.

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

Similar Threads

  1. Replies: 14
    Last Post: 12-01-2015, 02:55 PM
  2. Replies: 12
    Last Post: 11-17-2014, 01:33 PM
  3. Issues with subform and master form
    By asmith533 in forum Forms
    Replies: 14
    Last Post: 09-24-2012, 09:13 AM
  4. Resizing a subform
    By tobydobo in forum Forms
    Replies: 3
    Last Post: 09-29-2011, 11:43 PM
  5. subform to open form w/ active master record
    By spitfire122 in forum Access
    Replies: 1
    Last Post: 06-28-2011, 04:28 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