Avatar of Thirt
Thirt

asked on 

Positioning/resizing Subforms based on users Res

I've been making progress with the help of the experts here to resize subforms. I have a main form (frmnewestimates) that gets maximized at load time, The subforms have been hard coded to their positions and are not maximizing with the main form. There are two subforms. The Tasks subform is on top of the Effort Sub form.
I have the following code working to widen the sub forms to the max:
    Me.sfrmTasks.Width = Me.InsideWidth
    Me.sfrmEffort.Width = Me.InsideWidth

Now I would like to dynamically assign the height to the sub forms so that the Tasks subform gets 40% of the space, and the Effort subform gets the remain space, which works out to about 32% of the total InsideHieigt of the main form, leaving the rest for the Main form header and footer.

I'm able to set the height of the Tasks subform only by using the following code in the sub form's ON LOAD event:
    Me.InsideHeight = Forms!frmnewestimates.InsideHeight * 0.4241
The problem I run into now is setting the Top position and height for the second subform (Effort) that goes directly under the first subform (Tasks). I've tried the following Main form ON LOAD event:
    Me.sfrmEffort.Top = Me.sfrmTasks.Top + Me.sfrmTasks.Height + 200
    Me.sfrmEffort.Height = Me.InsideHeight * 0.32
I've tried setting the Top and Height with hard coded numbers, but I just can't get it to budge that subform. Any ideas how to position that subform properly? I've tried to do it from the subform's ON LOAD, but there is no TOP value available to set.

Thanks!!!
Microsoft Access

Avatar of undefined
Last Comment
stevbe
ASKER CERTIFIED SOLUTION
Avatar of stevbe
stevbe

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of stevbe
stevbe

oops ...
< 32%> ... well, maybe on the resolution you are developing in but you really should finish out the math using the actual control positions ... always make sure if you are adding / subtracting the bits and pieces that you nest them or make sure the order your logic matches VBA's order of math operations.

 Me.sfrmEffort.Height = 0
 Me.sfrmEffort.Top = Me.sfrmTasks.Top + Me.sfrmTasks.Height + 200
 Me.sfrmEffort.Height = Me.InsideHeight - Me.sfrmEffort.Top + 200
Avatar of Thirt
Thirt

ASKER

I moved the ON LOAD code to On Resize and now it works great! I still had an issue with the effort subform not moving, but remember that on load code I had in TASK to set it's height? I took it out and moved it to the main form resize and now everything works perfectly.  Thanks!!!
Avatar of Thirt
Thirt

ASKER

I thought using the percentages would be better then using hard coded numbers. I actually removed the 200 padding and it's looks great on my res.
    Me.sfrmTasks.Width = Me.InsideWidth
    Me.sfrmEffort.Width = Me.InsideWidth
    Me.sfrmTasks.Height = Me.InsideHeight * 0.4241
    Me.sfrmEffort.Height = 0
    Me.sfrmEffort.Top = Me.sfrmTasks.Top + Me.sfrmTasks.Height
    Me.sfrmEffort.Height = Me.InsideHeight * 0.32

However, on a PC wilth a smaller res, the bottom of the effort sub form is getting cut off. And that's a problem since there are ADD record buttons on the bottom of the form. So I'm tweaking with the percentages, but I think I need a better routine to calculate what makes 40% and 30% of the available space.
Avatar of Thirt
Thirt

ASKER

I guess what I need to do is keep the height setting for the task sub form to 40%. But how do I now figure out the remaining space between the bottom of the task subform down to the top of the main form footer?
Avatar of Thirt
Thirt

ASKER

OK, I think I almost have it. using the following:
    Me.sfrmTasks.Width = Me.InsideWidth
    Me.sfrmEffort.Width = Me.InsideWidth
    Me.sfrmTasks.Height = (Me.InsideHeight - Me.FormHeader.Height - Me.FormFooter.Height) * 0.6
    Me.sfrmEffort.Height = 0
    Me.sfrmEffort.Top = Me.sfrmTasks.Top + Me.sfrmTasks.Height
    Me.sfrmEffort.Height = (Me.InsideHeight - Me.FormHeader.Height - Me.FormFooter.Height) * 0.4

That's giving 60% to the task subform, and 40% to the effort subform. Perfect. The only problem is, when the form loads, the effort subform is getting cut off at the bottom. But if I restore down the form (making the access window smaller), it looks perfect. And if I maximize the application, again it looks perfect. So I wonder what I need to do to get the settings to take place at start up?
Avatar of stevbe
stevbe

<the effort subform is getting cut off at the bottom>
by how much? I have noticed that *sometimes* that if I have drawn a liner at the very bottom of the form it do not get displayed poperly, I don';t think it is a sizing issue for me as much as a display issue ... maybe you could have a Me.Repaint to force the form to re-draw itself ?

Steve
Avatar of Thirt
Thirt

ASKER

Been playing around with the repaint...still no effort. May I send you the screenshots?
Avatar of Thirt
Thirt

ASKER

Nevermind, I'm an idiot. I left a hieight size call in the second subform on load. Since it's now done in the main form event, I removed it from the sub form and all is perfect. Thanks!
Avatar of stevbe
stevbe

<I'm an idiot. >   NOT!!!
Think about what you now have you app doing ... automatically sizing itself independant of screen size and resolution. These are the very things that once you learn you can easily incorporate into other places and apps, making it easy for you to make your business tools look great also.  How far dowm that road do you want to go? One of my next favorite, simple form treatments is to use windows constants for the properties of controls that you set colors on. When the user changes their desktop theme you app still looks great (while you might not like the theme they chose, they apparently like it). What I do is create 1 form that has 1 of each type of control in each of the header, detail and footer sections. Then I set the colors properties to the windows constants and finally, and here is the really cool part, you can save that format and apply it to any form in any app :-)

Steve
Avatar of Thirt
Thirt

ASKER

Thanks! I'm really happy with the results. And I will be apply the same technique to the other internal apps. I'm playing with the idea to allow the user to specify the percentage amount of the subforms, as some users might want the ratios set differently. But you are right....how far down the road to I plan to go. Thanks again!
Avatar of stevbe
stevbe

<I'm playing with the idea to allow the user to specify the percentage amount of the subforms>
Honestly ... I don't think this would be very good for users to handle ... I also don't think they would use it much.

It is a fine balance between "looks great, very friendly" and "stop with the eye candy"

Good luck working it all out ... EE is here for you :-)

Steve
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo