MoveSize Subfrom

A

alex

MoveSize Subfrom

Hello,

Using Access ’03…

I have a form that’s opened and sized depending on the number of
records provided (either as a continuous form or datasheet).

Here’s the code (modified from a previous form):

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

Dim RecordCount As Long
RecordCount = DCount("*", "tblAlpha")
'Debug.Print (RecordCount)
'form has Header, Detail, and Footer
DoCmd.MoveSize , , , (Me.Detail.Height * RecordCount) _
+ FormTopMargin

In this form, however, there’s a subform that also needs to be sized
with the RecordCount.

I’ve tried to do this, but no avail…I thought maybe instead of sizing
the subform based on the RecordCount, to size the subform relative to
the main form.

Any ideas?
Thanks,
alex
 
A

Arvin Meyer [MVP]

Remember the subform is a Control, not a form, until you get it's form
properties. The RecordCount of the subform can be determined in the Current
even of the main form (aircode):

Sub Form_Current()
Dim x
x = Me.SubformControlName.Form.RecordsetClone.RecordCount

' Now do something with the subform control
Me.SubformControlName.Height = 150 * x

End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

MoveSize Subfrom

Hello,

Using Access ’03…

I have a form that’s opened and sized depending on the number of
records provided (either as a continuous form or datasheet).

Here’s the code (modified from a previous form):

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

Dim RecordCount As Long
RecordCount = DCount("*", "tblAlpha")
'Debug.Print (RecordCount)
'form has Header, Detail, and Footer
DoCmd.MoveSize , , , (Me.Detail.Height * RecordCount) _
+ FormTopMargin

In this form, however, there’s a subform that also needs to be sized
with the RecordCount.

I’ve tried to do this, but no avail…I thought maybe instead of sizing
the subform based on the RecordCount, to size the subform relative to
the main form.

Any ideas?
Thanks,
alex
 
A

alex

Remember the subform is a Control, not a form, until you get it's form
properties. The RecordCount of the subform can be determined in the Current
even of the main form (aircode):

Sub Form_Current()
Dim x
x = Me.SubformControlName.Form.RecordsetClone.RecordCount

' Now do something with the subform control
    Me.SubformControlName.Height = 150 * x

End Sub
--
Arvin Meyer, MCP, MVPhttp://www.datastrat.comhttp://www.mvps.org/accesshttp://www.accessmvp.com


MoveSize Subfrom

Hello,

Using Access ’03…

I have a form that’s opened and sized depending on the number of
records provided (either as a continuous form or datasheet).

Here’s the code (modified from a previous form):

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

Dim RecordCount As Long
RecordCount = DCount("*", "tblAlpha")
'Debug.Print (RecordCount)
'form has Header, Detail, and Footer
    DoCmd.MoveSize , , , (Me.Detail.Height * RecordCount) _
    + FormTopMargin

In this form, however, there’s a subform that also needs to be sized
with the RecordCount.

I’ve tried to do this, but no avail…I thought maybe instead of sizing
the subform based on the RecordCount, to size the subform relative to
the main form.

Any ideas?
Thanks,
alex

Thank-you very much Arvin for the advice/example.
It took me a few tries to get the calculation right...but it works
great.
I also set the sfrm height right from the main form, since I was
calculating the record count there anyway!
Thanks again for your expertise.
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

Similar Threads

Docmd.Movesize 6

Top