Resizing the Details Section Height and Width.

S

Stewart Berman

Access 2007

I have a form with a header width a few controls and a details section with
five sub form controls. The resize event of the form with resize and
position the controls so they are fully visible as the user changes the size
of the form window. There appears to be a problem with the detail section.

If the user enlarges the form all is well. The five sub form controls are
positioned and increased in size and they are all visible. Neither the
vertical nor the horizontal scrollbar is visible.

If the user shrinks the from the five sub form controls are positioned and
reduced in size so they are all visible. However the vertical and
horizontal scrollbars appear and if they are slide right or down they expose
the unused portion of the details section which does not automatically
shrink. (Note: I have set the detail section's grow and shrink properties
to yes.)

I then tried to adjust the height of the detail section at the end of the
resize event. This causes at least one of the sub form control's form to be
reloaded. (It might affect all five but the first one throws an error.)

The code that seemed to cause the problem was the last two lines of the
form's Resize event:
Me.Detail.Height = sf_Bottom_Left.Top + sf_Bottom_Left.Height
Me.Width = sf_Top.Width

If I comment out those two lines every thing is fine as long the user either
doesn't change the size of the form's window or one increases it. If the
decrease it I get the scrollbars and the user can scroll into the empty
space of the detail section.

I finally turned off both scrollbar and set a minimum windowheight and
windowwidth via the Resize event.

However, I would like to understand what is going on. Why does changing the
size of the detail section cause the sub form controls' forms to be loaded
again even though they are already loaded?

I also would like to know how to safely resize the detail section in case I
do need to have scrollbars. Right now if I enable the scrollbars and the
user maximizes and then restores the form over half of the scrollbar is
dedicated to empty space.
 
M

Marshall Barton

Stewart said:
Access 2007

I have a form with a header width a few controls and a details section with
five sub form controls. The resize event of the form with resize and
position the controls so they are fully visible as the user changes the size
of the form window. There appears to be a problem with the detail section.

If the user enlarges the form all is well. The five sub form controls are
positioned and increased in size and they are all visible. Neither the
vertical nor the horizontal scrollbar is visible.

If the user shrinks the from the five sub form controls are positioned and
reduced in size so they are all visible. However the vertical and
horizontal scrollbars appear and if they are slide right or down they expose
the unused portion of the details section which does not automatically
shrink. (Note: I have set the detail section's grow and shrink properties
to yes.)

I then tried to adjust the height of the detail section at the end of the
resize event. This causes at least one of the sub form control's form to be
reloaded. (It might affect all five but the first one throws an error.)

The code that seemed to cause the problem was the last two lines of the
form's Resize event:
Me.Detail.Height = sf_Bottom_Left.Top + sf_Bottom_Left.Height
Me.Width = sf_Top.Width

If I comment out those two lines every thing is fine as long the user either
doesn't change the size of the form's window or one increases it. If the
decrease it I get the scrollbars and the user can scroll into the empty
space of the detail section.

I finally turned off both scrollbar and set a minimum windowheight and
windowwidth via the Resize event.

However, I would like to understand what is going on. Why does changing the
size of the detail section cause the sub form controls' forms to be loaded
again even though they are already loaded?

I also would like to know how to safely resize the detail section in case I
do need to have scrollbars. Right now if I enable the scrollbars and the
user maximizes and then restores the form over half of the scrollbar is
dedicated to empty space.


There are two issues there. Changing the detail section
height does not change the size of the form nor is it legal
to make the section shorter than the bottom of the bottom
most control in the section. The available vertical space
for the detail section that is displayed is whatever is left
over after the form header and footer section's are
displayed. You should make the detail section's Height big
enough in design view for when the form is maximized and
then leave it alone.

Also, you should be very careful when setting the form's
Width property, especially when making it narrower. Because
it will not allow you to set the Width so the right edge of
the form is to the left of the right side of any control,
things might not do what you think they should do. If you
really need to set the form's Width (and I have trouble
imagining such a situation), then you need to follow the
general rule of making the form wider before enlarging or
positioning the controls to the right. Conversely, you need
to make the controls smaller and/or position them to the
left before making the form narrower.

You are probably already doing this when you check and set
the form's minimum size, but the form's display size is
determined by the form's InsideHeight and InsideWidth
properties. You can use InsideHeight minus header and
footer heights to determine how much space is available for
the detail section and adjust the subform heights so they
fit. The InsideWidth will tell you how wide you can make
the subforms so you won't need the main form's scroll bars.

Are you sure the subform's are being reloaded? They will be
repainted in some cases, but a full blown requery seems to
me to be overkill.

The CanGrow/Shrink properties are only used when you print
the form so those are irrelevant to your question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top