Change a Forms Detail Section Height Programmatically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to create a toggle button which allows a user to change the height of
a detail section from one height to another. Does anyone know how I can do
this with Visual Basic?

Thanks,

Sarah
 
Sarah said:
I want to create a toggle button which allows a user to change the height of
a detail section from one height to another. Does anyone know how I can do
this with Visual Basic?


The height of the detail section in a form is whatever space
is left over in the form's window after the header and
footer sections are displayed. What that boils down to is
that you have to use the form's InsideHeight property to
change the height of the form.

If you need additional assistance, please provide more
details about the form (header/footer and how you determine
when and how much to change the detail height).
 
What I really want to do is change the detail section height depending on the
display Settings chosen for the screen area in the Control Panel.

For example:
screen area=1152 by 864 pixels
I want the detail section to be larger - displaying more records.

screen area=1024 by 768 pixels
I want the detail section to be smaller - displaying less records.

This is the code I have in the forms OnActivate:

Dim intWindowHeight As Integer
Dim intWindowWidth As Integer
Dim intTotalFormHeight As Integer
Dim intTotalFormWidth As Integer
Dim intHeightHeader As Integer
Dim intHeightDetail As Integer
Dim intHeightFooter As Integer
Dim frm As Form

Set frm = [Forms]![frmmtm]
' Determine form's height.
intHeightHeader = frm.Section(acHeader).Height
intHeightDetail = frm.Section(acDetail).Height
intHeightFooter = frm.Section(acFooter).Height
intTotalFormHeight = intHeightHeader _
+ intHeightDetail + intHeightFooter
' Determine form's width.
intTotalFormWidth = frm.Width
' Determine window's height and width.
intWindowHeight = frm.InsideHeight
intWindowWidth = frm.InsideWidth

If intWindowWidth <> intTotalFormWidth Then
frm.InsideWidth = intWindowWidth
End If
If intWindowHeight <> intTotalFormHeight Then
frm.InsideHeight = intWindowHeight
frm.Section(acDetail).Height = frm.Section(acDetail).Height +
Abs(intWindowHeight - intTotalFormHeight)
End If

Any help is greatly appreciated!!!!
 
I should mention one more thing. The detail section contains a subform which
I want to grow or shrink depending on the size of the detail section.

Sarah said:
What I really want to do is change the detail section height depending on the
display Settings chosen for the screen area in the Control Panel.

For example:
screen area=1152 by 864 pixels
I want the detail section to be larger - displaying more records.

screen area=1024 by 768 pixels
I want the detail section to be smaller - displaying less records.

This is the code I have in the forms OnActivate:

Dim intWindowHeight As Integer
Dim intWindowWidth As Integer
Dim intTotalFormHeight As Integer
Dim intTotalFormWidth As Integer
Dim intHeightHeader As Integer
Dim intHeightDetail As Integer
Dim intHeightFooter As Integer
Dim frm As Form

Set frm = [Forms]![frmmtm]
' Determine form's height.
intHeightHeader = frm.Section(acHeader).Height
intHeightDetail = frm.Section(acDetail).Height
intHeightFooter = frm.Section(acFooter).Height
intTotalFormHeight = intHeightHeader _
+ intHeightDetail + intHeightFooter
' Determine form's width.
intTotalFormWidth = frm.Width
' Determine window's height and width.
intWindowHeight = frm.InsideHeight
intWindowWidth = frm.InsideWidth

If intWindowWidth <> intTotalFormWidth Then
frm.InsideWidth = intWindowWidth
End If
If intWindowHeight <> intTotalFormHeight Then
frm.InsideHeight = intWindowHeight
frm.Section(acDetail).Height = frm.Section(acDetail).Height +
Abs(intWindowHeight - intTotalFormHeight)
End If

Any help is greatly appreciated!!!!

Marshall Barton said:
The height of the detail section in a form is whatever space
is left over in the form's window after the header and
footer sections are displayed. What that boils down to is
that you have to use the form's InsideHeight property to
change the height of the form.

If you need additional assistance, please provide more
details about the form (header/footer and how you determine
when and how much to change the detail height).
 
Whoa! That subject is too complex to deal with in newsgroup
posts. You may want to follow the links at
http://www.mvps.org/access/general/gen0002.htm
for more information.

If you know what the heights are apriori, then you can just
set the forms InsideHeight to those values:

If Me.toggle = True Then
Me.InsideHeight = 5 * 1440 '5 Inches high
Me.subform.Height = 3 * 1440 '3 Inches high
Else
Me.InsideHeight = 3 * 1440 '3 Inches high
Me.subform.Height = 1 * 1440 '1 Inch high
End If
--
Marsh
MVP [MS Access]

What I really want to do is change the detail section height depending on the
display Settings chosen for the screen area in the Control Panel.

For example:
screen area=1152 by 864 pixels
I want the detail section to be larger - displaying more records.

screen area=1024 by 768 pixels
I want the detail section to be smaller - displaying less records.

This is the code I have in the forms OnActivate:

Dim intWindowHeight As Integer
Dim intWindowWidth As Integer
Dim intTotalFormHeight As Integer
Dim intTotalFormWidth As Integer
Dim intHeightHeader As Integer
Dim intHeightDetail As Integer
Dim intHeightFooter As Integer
Dim frm As Form

Set frm = [Forms]![frmmtm]
' Determine form's height.
intHeightHeader = frm.Section(acHeader).Height
intHeightDetail = frm.Section(acDetail).Height
intHeightFooter = frm.Section(acFooter).Height
intTotalFormHeight = intHeightHeader _
+ intHeightDetail + intHeightFooter
' Determine form's width.
intTotalFormWidth = frm.Width
' Determine window's height and width.
intWindowHeight = frm.InsideHeight
intWindowWidth = frm.InsideWidth

If intWindowWidth <> intTotalFormWidth Then
frm.InsideWidth = intWindowWidth
End If
If intWindowHeight <> intTotalFormHeight Then
frm.InsideHeight = intWindowHeight
frm.Section(acDetail).Height = frm.Section(acDetail).Height +
Abs(intWindowHeight - intTotalFormHeight)
End If

Any help is greatly appreciated!!!!

Marshall Barton said:
The height of the detail section in a form is whatever space
is left over in the form's window after the header and
footer sections are displayed. What that boils down to is
that you have to use the form's InsideHeight property to
change the height of the form.

If you need additional assistance, please provide more
details about the form (header/footer and how you determine
when and how much to change the detail height).
 
Back
Top