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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can user size portions of form

Status
Not open for further replies.

illuzioner

Technical User
Dec 15, 2002
44
US
Hi,

Is there a way to let the user size the details portion of a form to hi/her taste? I know i set the dimensions of the form in a macro, but as far as I know that would require the user to enter the size they want.

I'd like something like in Excel where they could drag a line higher or lower ro resize a window -- not the whole form, just the details vs. footer portions.

Thanks!

Lou
 
Set the Border Style property of the form to Sizable. This will allow the user to resize the form to whatever dimensions they want. If you want to limit what they can resize and whether controls in the form resize along with the form you need to play with the form's InsideWidth and InsideHeight properties.

For example: In the form's class module...


Option Compare Database
Option Explicit

Dim minimumFormWidth As Integer
Dim maximumFormWidth As Integer
Dim previousFormWidth As Integer
Dim minimumFormHeight As Integer
Dim maximumFormHeight As Integer
Dim previousFormHeight As Integer

Private Sub Form_Resize()
On Error GoTo Err_Form_Resize

Dim widthDifference As Integer
Dim heightDifference As Integer

If minimumFormWidth = 0 Then
minimumFormWidth = Me.InsideWidth
previousFormWidth = Me.InsideWidth
minimumFormHeight = Me.InsideHeight
previousFormHeight = Me.InsideHeight
End If

widthDifference = Me.InsideWidth - previousFormWidth
heightDifference = Me.InsideHeight - previousFormHeight

If Me.InsideWidth > minimumFormWidth Then
myListView.Width = myListView.Width + widthDifference
myButton.Left = myButton.Left + widthDifference
myFrame.Width = myFrame.Width + widthDifference
myCheckbox.Left = myCheckbox.Left + widthDifference
myLabel.Left = myLabel.Left + widthDifference

previousFormWidth = Me.InsideWidth
Else
Me.InsideWidth = minimumFormWidth
End If

If Me.InsideHeight > minimumFormHeight Then
Me.Detail.Height = Me.Detail.Height + heightDifference
myListView.Height = myListView.Height + heightDifference
myButton.Top = myButton.Top + heightDifference
myFrame.Top = myFrame.Top + heightDifference
myLabel.Top = myLabel.Top + heightDifference
myCheckbox.Top = myCheckbox.Top + heightDifference

previousFormHeight = Me.InsideHeight
Else
Me.InsideHeight = minimumFormHeight
End If

Exit_Form_Resize:
Exit Sub

Err_Form_Resize:
msgbox err.Description
Resume Exit_Form_Resize

End Sub
 
Hi Schof,

Thanks for the reply. I haven't had an opportunity to implement it, but I will check it out.

Thanks again.

Lou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top