Results 1 to 2 of 2

Thread: resize/undock

  1. #1
    Join Date
    Sep 2010

    Question Unanswered: resize/undock

    I have 2 subforms in a form. The 2 subforms are datasheet forms. I want the user to be able to resize the datasheet subforms to the size they want without going to the design view. Just like it is done on design view where you click on the corner and drag it to the size you want. How can I do this?

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 15
    You can use the Height and Width properties of a subform/subreport control to resize it. Here is an excerp from a program where several subforms controls move or change of size when the parent form is resized. In this example m_clsChildren is an instance of a class that holds (among other things) the name of the different subform controls. You can simply replace it with the name of the control (m_clsChildren.ChildListName --> ChildListName, etc...).
    Private Sub Form_Resize()
        Static lngNonListHeight As Long
        Static lngNonListWidth As Long
        Static lngButtonsRight As Long
        Static lngNonFiltersWidth As Long
        If m_booReady = False Then m_booReady = GatherChildren
        If Len(m_clsChildren.ChildListName) > 0 Then
            If lngNonListHeight = 0 Then lngNonListHeight = Me.WindowHeight - Me.Controls(m_clsChildren.ChildListName).Height
            If Me.WindowHeight - lngNonListHeight > 0 Then Me.Controls(m_clsChildren.ChildListName).Height = Me.WindowHeight - lngNonListHeight
            If lngNonListWidth = 0 Then lngNonListWidth = Me.WindowWidth - Me.Controls(m_clsChildren.ChildListName).Width
            If Me.WindowWidth - lngNonListWidth > 0 Then Me.Controls(m_clsChildren.ChildListName).Width = Me.WindowWidth - lngNonListWidth
        End If
        If Len(m_clsChildren.ChildButtonsName) > 0 Then
            If lngButtonsRight = 0 Then lngButtonsRight = Me.WindowWidth - Me.Controls(m_clsChildren.ChildButtonsName).Left
            If Me.WindowWidth - lngButtonsRight > 0 Then Me.Controls(m_clsChildren.ChildButtonsName).Left = Me.WindowWidth - lngButtonsRight
        End If
        If Len(m_clsChildren.ChildFiltersName) > 0 Then
            If lngNonFiltersWidth = 0 Then lngNonFiltersWidth = Me.WindowWidth - Me.Controls(m_clsChildren.ChildFiltersName).Width
            If Me.WindowWidth - lngNonFiltersWidth > 0 Then Me.Controls(m_clsChildren.ChildFiltersName).Width = Me.WindowWidth - lngNonFiltersWidth
        End If
    End Sub
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts