Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

resize/undock

Status
Not open for further replies.

abenitez77

IS-IT--Management
Oct 18, 2007
147
US
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?
 
You may be able to play with this idea to capture the mouse events. I did not play with it enough to get that to work. Here is a simple way. I addes to MSFORMS spin buttons from the "Insert Active X Control" in the Tool Box. I made one vertical and one horizontal created the following effect in the upper left corner of the subform:
< >
^
V

Code:
Private Sub Form_Load()
  Dim spnBtnV As MSForms.SpinButton
  Dim spnBtnH As MSForms.SpinButton
  Set spnBtnV = Me.spnBtnVertical.Object
  Set spnBtnH = Me.spnBtnHorizontal.Object
  spnBtnV.SmallChange = 200
  spnBtnH.SmallChange = 200
  spnBtnV.Max = 10000
  spnBtnH.Max = 10000
  subFrmWidth = Me.Orders_Subform.Width
  subfrmHeight = Me.Orders_Subform.Height
  spnBtnV.Min = -10000
  spnBtnH.Min = -1 * subFrmWidth

End Sub
Private Sub spnBtnHorizontal_Change()
  Me.Orders_Subform.Width = subFrmWidth + (Me.spnBtnHorizontal)
End Sub

Private Sub spnBtnVertical_Change()
   'Down arrow is decreasing value and makes the subform move downwards
   If subfrmHeight > Me.spnBtnVertical Then
     Me.Orders_Subform.Height = subfrmHeight + -1 * (Me.spnBtnVertical)
   Else
     Me.Orders_Subform.Height = 0
   End If
End Sub
This allows the subforms to resize.
 
I typically take advantage of as much screen as there is available with code in the Main form's resize like:
Code:
Private Sub Form_Resize()
   On Error GoTo Form_Resize_Error
   'form has a header
   Me.SubForm.Height = Me.InsideHeight - (Me.Section(1).Height + Me.SubForm.Top + 100)
   Me.SubForm.Width = Me.InsideWidth - 200

   On Error GoTo 0
   Exit Sub

Form_Resize_Error:

    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_Resize of VBA Document Form_frmMyQueryResults"
End Sub

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top