472,958 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

Adjust the heights and widths of multiple subforms without additional controls

A while back I got a requirement for the client to be able to adjust
the relative heights of two subforms by click-dragging the mouse and I
came up with a kludge solution using a border control between the two
subforms. But I put my mind to this again recently and came up with a
solution (code below) that works well with multiple subforms to size
both the heights and widths of the sunforms relative to each other, and
it uses no additional controls.
I throw this code out in case others have the same needs and also in
the hopes someone will see some ways to improve it.
To use this code:
Create a form. On the main form place a subform named Child1 on the
left side of the main form so that it takes up the whole height of the
main form but only half the width. On the right side of the main form
place a subform named Child2 so that its top lines up with Child1 and
takes up the remaining width of the main form to the right of Child1.
Then place a subform named Child3 under Child2 so that it takes up the
remainign space on the main form. What you have is a main form divided
into two columns, with three subforms. In the left column Child1 takes
up the whole height of the main form and in the right column, the
height is equally divided between Child2 and Child3.

When you click the left mouse button and drag in the spaces between the
subforms you'll be able to adjust the position of the vertical column
that seperates Child1 from Child2 and Child3, as well as adjust the
heights of Child2 and Child3
Private isSizingVert As Boolean
Private isSizingHorz As Boolean
Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, x As
Single, Y As Single)
On Error GoTo myErr

Dim c2Bot As Long, c1Rt As Long

'resize verical
c2Bot = Me.Child2.Top + Me.Child2.Height

If Y c2Bot - 100 And Y < c2Bot + 100 And x Me.Child2.Left Then
Screen.MousePointer = 7
isSizingVert = True
Screen.MousePointer = 0
If Button < 1 Then isSizingVert = False
End If

If Button = 1 And isSizingVert = True Then
Screen.MousePointer = 7
isSizingVert = True
If Y Me.Child2.Top + 725 And Y < (Me.InsideHeight +
Me.FormHeader.Height) - 2000 Then
Me.Child2.Height = Y - Me.Child2.Top
Me.Child3.Height = (Me.Child1.Height + Me.Child1.Top) - (Y
+ 575)
Me.Child3.Top = Y + 575
End If
End If

'resize horizontal
c1Rt = Me.Child1.Left + Me.Child1.Width

If x c1Rt - 100 And x < c1Rt + 100 And x < Me.InsideWidth * 0.7
And Y Me.Child1.Top Then
Screen.MousePointer = 9
isSizingHorz = True
If Screen.MousePointer < 7 Then
Screen.MousePointer = 0
If Button < 1 Then isSizingHorz = False
End If
End If

If Button = 1 And isSizingHorz = True Then
isSizingHorz = True
If x Me.Child1.Left + 3000 And x < Me.InsideWidth * 0.7
Me.Child1.Width = x - Me.Child1.Left
Me.Child2.Width = Me.InsideWidth - (Me.Child1.Width +
Me.Child2.Left = x + 100
Me.Child3.Width = Me.Child2.Width
Me.Child3.Left = Me.Child2.Left
End If
End If

Exit Sub
MsgBox Err.Number & " - " & Err.Description
Resume myExit
End Sub

Nov 13 '05 #1
7 2271
Hi Lauren,

I had some problems getting the code to work:
- Looks like the greater than signs didn't come through in the post. I
threw some in.
- I found that the main form needs a Form Header section. You could
test for that to make it flexible.

I haven't spent time to look at the code in detail, but here are some
- Pretty cool!
- The cursor doesn't change back to regular when you're done adjusting.
You'd probably need to call the MouseMove in the subforms to do that?
Could set that at runtime.
- It does take quite a lot of processor time while you're dragging.
Display the performance tab of the Task Manager while you're doing it.
- My border between Child2 and Child3 jumped to like .5 inch and stayed
that way. (Of course, I was throwing >'s around with abandon).


Nov 13 '05 #2
Bummer the ">" signs somehow got convetred to "-" in the post.

Nov 13 '05 #3
lauren quantrell wrote:
I throw this code out in case others have the same needs and also in
the hopes someone will see some ways to improve it.

Thank you very much for this. I'll be trying it soon.
Tim http://www.ucs.mun.ca/~tmarshal/
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #4
Not that some of the ">" signs got switched to "-" during the post in
the If Than statements

Nov 13 '05 #5
I'm not sure but since the subforms are loaded with (ADO) recordsets it
looks like the subforms are requerying as they are being resized, which
might explain the 100% CPU usage during resize. My first thought...

Nov 13 '05 #6
I've experienced this with MouseMove and read about it in other posts.
Every time the mouse moves a pixel, the code runs. And your code is
fairly complex.

Nov 13 '05 #7
Yes, the form has a FormHeader and in the subforms I put OnMouseMove to
set the screen.cursor back to "0."
Also on FormDeactivate I set the screen.cursor back to "0". I forgot to
mention that.
I leave a .5" space between Child2 and Child3 because I have labels in
there. You can adjust that to fit your needs.

Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: cpt | last post by:
I read that if one uses "table-layout:fixed" then table rendering is speeded by setting row height. All my rows are 285 px high. 1) Is this true? 2) If true, how does one set row-height for the...
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a form with multiple pages on it. There is one text field on the third page of the form that I need the user to complete before leaving the form or moving...
by: Jenni | last post by:
I currently have a query that is joining two distinct pools of information and turning them into one records with a unique identifier This query is dependent on criteria passed from a form in a...
by: Steve | last post by:
I have a form, primary subform and secondary subform. A tab control takes up all the area of the primary subform. There are about 15 tabs on the tabcontrol. Each tab contains fields from the same...
by: Wadim Grasza | last post by:
I want to store and display (on a form or a report) multiple pictures per record in an access database. The pictures are not stored within the database. They are stored as files and the database...
by: microb0x | last post by:
I have an application with a master form with a tab control containing nine tabs, each tab contains a subform. I have command buttons on my main form including: Save , Cancel , Close. My...
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform relates to the main form using an identity key (this works). The second subform relates to both the main and first subform. But I want to...
by: isoquin | last post by:
Hello- I have one form frmProject1 (record source tblProject1), with two subforms within it: 1) frmPayroll (tblPayroll), and 2) frmTimes (tblTimes) Basically, there are multiple different...
by: Gord | last post by:
If possible, how can the user be prevented from adjusting the column width and/or the row height in datasheet view (in VB code if necessary)? (I still want them to be able edit the contents of the...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.