Resize Pop Up Form

A

alex

Hello,

Using Access ’03…

I have a pop up form that opens on top of another form. The pop up
default view is “continuous forms.” The form is simply for show—no
data entry.

Sometimes the pop up contains 5 records; sometimes it contains 25
records.

I need the pop up to open and dynamically resize itself based on the
number of records; e.g., the form would be taller with 25 records as
opposed to 5 records. (Auto Resize does not work)

I’ve done some searching and cannot find a solution. I think a
possible workaround would be to add code in the pop up’s on open event
and dynamically adjust it based on a dcount, but I’m not sure.

Thanks,
alex
 
O

Oliver Straub

Hi,

alex said:
I need the pop up to open and dynamically resize itself based on the
number of records; e.g., the form would be taller with 25 records as
opposed to 5 records. (Auto Resize does not work)
I’ve done some searching and cannot find a solution. I think a
possible workaround would be to add code in the pop up’s on open event
and dynamically adjust it based on a dcount, but I’m not sure.

you coud use the load-event:

Private Sub Form_Load()
Dim iRows As Integer

iRows = Me.Recordset.RecordCount
If iRows > 25 Then
iRows = 25
ElseIf iRows < 5 Then
iRows = 5
End If

Me.Move Me.WindowLeft, , , Me.WindowHeight - Me.InsideHeight + _
Me.Section(acHeader).Height + Me.Section(acFooter).Height + _
iRows * Me.Section(acDetail).Height

End Sub

Just only use the sections you need for your form. (Header/Footer)
 
P

Peter Hibbs

Alex,

You are correct, try this code in the Open event of the pop up form.

Private Sub Form_Open(Cancel As Integer)

Const FormTopMargin = 560
Const FormScrollBar = 250
Const FormRecSelectors = 250

Dim RecordCount As Long

RecordCount = DCount("*", "YourTable", "YourCriteria")
DoCmd.MoveSize , , , Me.FormHeader.Height _
+ Me.FormFooter.Height _
+ (Me.Detail.Height * RecordCount) _
+ FormTopMargin _
+ FormScrollBar _
+ FormRecSelectors

End Sub

You will need to tell the routine the number of records that will be
displayed in the form. Replace YourTable with the name of the table or
query. If there is any criteria which changes the number of records
then enter that in place YourCriteria in the DCount function.

If you do not have horizontal scroll bar enabled then set the constant
Const FormScrollBar = 0

If you do not have Navigation Buttons enabled then set the constant
Const FormRecSelectors = 0

If you have a different Border Style than Sizable you my need to
adjust the constant FormTopMargin to a different value.

HTH

Peter Hibbs.
 
W

Wayne-I-M

Hi Alex

I never thought of doing that - good idea.

Just had a play around with 2 methods and it's quite simple (sort of ;-)

1st method
Use the twips size of the box to alter it. Don't forget that 1440 = 1 inch
OnOpen of the form use recordwsert count then set the width and section size
from that
You need to come up with a formula that you're happy with

something like
Me.Width = me. put recordset count here / (1 * 1440)
do the same with Me.Section.Height


2nd method
use DoCmd.MoveSize in vba
Tip - just type DoCmd.MoveSize on code window then click it and press F1 and
you will get the details
Again use the the recordset count to get you the base number then * or /
depending on the count

For both don't forget to leave enough room for the form headers and footers
(if you have them)


HTH
 
A

alex

Hi Alex

I never thought of doing that - good idea.

Just had a play around with 2 methods and it's quite simple (sort of ;-)

1st method
Use the twips size of the box to alter it.  Don't forget that 1440 = 1 inch
OnOpen of the form use recordwsert count then set the width and section size
from that
You need to come up with a formula that you're happy with

something like
Me.Width = me. put recordset count here / (1 * 1440)
do the same with Me.Section.Height

2nd method
use DoCmd.MoveSize in vba  
Tip - just type DoCmd.MoveSize on code window then click it and press F1 and
you will get the details
Again use the the recordset count to get you the base number then * or /
depending on the count

For both don't forget to leave enough room for the form headers and footers
(if you have them)

HTH

--
Wayne
Manchester, England.











- Show quoted text -

Wow! Thanks guys for the help...
I'm going to try some of the code and post back if I have questions.
Thanks again!
alex
 

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