Discussion:
programmatically changing size of continuous form
(too old to reply)
JohnB
2007-11-10 00:45:34 UTC
Permalink
I've tried searching the internet in a variety of ways to get this one, but
can't find it. I have a continuous form that opens at first with no records
and the Detail section's visible property set to No. The user selects a
criteria from the combo box (e.g., cboCriteria) in the header, the
after_update event of which goes something like this:
lngID=me.cboCriteria
strSQL="SELECT * FROM tblMyTable WHERE ID=" &
lngID
me.recordsource=strSQL
me.Detail.visible=true
docmd.RunCommand acCmdSizeToFitForm

The above code does NOT seem to change the size of the form. What I
want to happen, if this is possible, is for the form to expand or shrink
depending on the number of records to be displayed in the Detail section,
and for the area displaying the data to grow or shrink each time the user
selects a new value from the combo box. The number of records to be
returned after each selection from the combo box varies only from 0 to 18,
so the form only needs to expand or shrink a few inches of screen height.
Is this possible?

I have wondered about this for years, and usually just find a way around it.
But now I just want to know. Thanks. --John
Minton M
2007-12-21 19:03:56 UTC
Permalink
Post by JohnB
I've tried searching the internet in a variety of ways to get this one, but
can't find it. I have a continuous form that opens at first with no records
and the Detail section's visible property set to No. The user selects a
criteria from the combo box (e.g., cboCriteria) in the header, the
lngID=me.cboCriteria
strSQL="SELECT * FROM tblMyTable WHERE ID=" &
lngID
me.recordsource=strSQL
me.Detail.visible=true
docmd.RunCommand acCmdSizeToFitForm
The above code does NOT seem to change the size of the form. What I
want to happen, if this is possible, is for the form to expand or shrink
depending on the number of records to be displayed in the Detail section,
and for the area displaying the data to grow or shrink each time the user
selects a new value from the combo box. The number of records to be
returned after each selection from the combo box varies only from 0 to 18,
so the form only needs to expand or shrink a few inches of screen height.
Is this possible?
I have wondered about this for years, and usually just find a way around it.
But now I just want to know. Thanks. --John
This questions seems to come up a lot and I know Stephen Lebans has
some code for manipulating continuous forms on his *excellent* website
http://www.lebans.com/.

The way I would do it is to calculate the height of each form in the
continuous form, work out how many records are in the recordsource and
use docmd.move to set the placement and size of the window. Eg. each
record is 200 twips, there are 10 records but we only want to show a
maximum of 5, so set DoCmd.Move ,,,1000.

-- James

Loading...