Set subform height with code

Good morning, I have a database with 3 tables and a form with a main form and two subforms, the checkbox is used to display the second subform.
I would like to know if it is possible to increase the height of the first subform when the second subform is not visible.
Thank you
example.odb (14.3 KB)

Have done this automatically for changing between small and big screen. Sized the tablecontrols in width and height.

You have to change this in the drawpage of the document, not in the properties of the form control. Something like

FOR i = 0 TO oDoc.DrawPage.Count -1
   oTableGraphic = oDoc.DrawPage.getByIndex(i)
   IF InStr(oTableGraphic.LinkDisplayName,"VarSize") > 0 THEN
      loGx = oTableGraphic.Size.Width
      loGy = oTableGraphic.Size.Height
      loGy = loGy * 2
      oSize = oTableGraphic.Size
      oSize.Width = loGx
      oSize.Height = loGy
      oTableGraphic.Size = oSize
   END IF
NEXT

will duplicate the height of the tablecontrol, which is named “VarSize”. This is the name which appears in navigator of the document, not in form navigator. It is “Forma2” in your example form, not “GridB”!

1 Like

Thanks, excellent, I attach a modified macro for my needs

Sub VisibileForm(oEv)
oForm = oEv.Source.Model.Parent
SubForm = oForm.GetByName("SubFormC")
GridC = SubForm.GetByName("GridC")
GridC.EnableVisible = oEv.Selected

oDoc = THISCOMPONENT
FOR i = 0 TO oDoc.DrawPage.Count -1
   oTableGraphic = oDoc.DrawPage.getByIndex(i)
   IF InStr(oTableGraphic.LinkDisplayName,"Forma2") > 0 Then
       loGx = oTableGraphic.Size.Width
	   loGy = oTableGraphic.Size.Height
      If oEv.Selected = 1 Then 
          loGy = loGy/2
      ElseIf oEv.Selected = 0  Then
         loGy = loGy * 2
      End If
          oSize = oTableGraphic.Size
	      oSize.Width = loGy 'New
	      oSize.Height = loGy'New
	      oTableGraphic.Size = oSize
   END IF
NEXT

End Su

Have change the code a little bit. Copied the code and doesn’t recognize the new values aren’t defined in the smaller code here.
Note: You have set width and height of the table by the same value loGy. Hope it is well in your code as loGx and loGy. Both variables are of type LONG.