Resize Parent Form on The Fly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dynamictiger
    New Member
    • Oct 2007
    • 4

    Resize Parent Form on The Fly

    I am building a wizard and have an issue with one sub form. Whilst all others are about 5 fields tall this one is 15 fields.

    My choices are either to resize the parent form ridiculously large for the other forms or resize the parent form on loading this subform.

    I have tried the following:

    Code:
     Me.Parent.Form.Section(acDetail).Height = 1.4 * Me.Parent.Form.Section(acDetail).Height
        
        'Me.Parent.Form.Section(acDetail).Repaint
        
        Me.Parent.Form.Repaint
    This is in the Form load event of the subform, but doesn't work. I have been trying various iterations of this and can't get it to work.

    Anyone got some code that works?
  • Zwoker
    New Member
    • Jul 2007
    • 66

    #2
    Hi,

    For what its worth I have some code that resizes the whole form when I need it. The code resides in my Form_Activate event. I run MS Access 2003. Maybe it will be of some help?

    Code:
    Const conInchesToTwips = 1440
    
    Me.Move Left:=Me.WindowLeft, Top:=Me.WindowTop, Width:=3.8 * conInchesToTwips, Height:=5.9 * conInchesToTwips
    I seem to recall there are some rules for using the Move method. Such as it not being allowed on Modal forms? Help for the command in your version of MS Access should give you the answers, if the method is of any use to you.


    Regards,
    Zwoker.

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      Originally posted by dynamictiger
      I am building a wizard and have an issue with one sub form. Whilst all others are about 5 fields tall this one is 15 fields.

      My choices are either to resize the parent form ridiculously large for the other forms or resize the parent form on loading this subform.

      I have tried the following:

      Code:
       Me.Parent.Form.Section(acDetail).Height = 1.4 * Me.Parent.Form.Section(acDetail).Height
          
          'Me.Parent.Form.Section(acDetail).Repaint
          
          Me.Parent.Form.Repaint
      This is in the Form load event of the subform, but doesn't work. I have been trying various iterations of this and can't get it to work.

      Anyone got some code that works?
      I hate to be the bearer of bad news but your code will never work, since Form Section Properties can only be modified in Form Design View. What you essentially need to do is to Close the Main Form, Open it in Design View, change the Detail Section dimensions, and the Open it again as in:
      [CODE=vb]
      'Assuming your Main Form is frmMain, and you are executing this code from an Event within the Sub-Form:
      DoCmd.Close acForm, "frmMain"
      DoCmd.OpenForm "frmMain", acDesign
      'Make changes while in Form Design View
      Application.Ech o False
      Me.Parent.Form. Section(acDetai l).Height = 1.4 * Me.Parent.Form. Section(acDetai l).Height
      Application.Ech o True
      DoCmd.OpenForm "frmMain", acNormal, , , acFormEdit[/CODE]

      Comment

      Working...