Docmd.Movesize

A

alex

Docmd.Movesize

Hello,

I have the following code that I’ve been using for several months.
It’s used to adjust the size of a form based on the number of records:

---------start code
Private Sub FormResize() 'code to resize both frmMainform and sfrm

Const DetailHeight = 240 'tried using me.detail.height but it didn't
work
'remember that the constant above will depend on how tall your textbox
(s)is
Const FormTopMargin = 560

Dim lngRecordCount As Long
lngRecordCount = Me.sfrm.Form.RecordsetClone.RecordCount '# of records

'form has Header, Detail
DoCmd.MoveSize , , , (DetailHeight * lngRecordCount) _
+ (Me.FormHeader.Height) + FormTopMargin

Me.sfrm.Height = (DetailHeight * lngRecordCount)
'Debug.Print (lngRecordCount)
'Debug.Print (Me.Detail.Height)

End Sub
---------end code

All of a sudden I’m getting this error: An expression you entered is
the wrong data type for one of the arguments (nothing changed, not
even the number of records!).
The debugger goes to this section of code:
DoCmd.MoveSize , , , (DetailHeight * lngRecordCount) _
+ (Me.FormHeader.Height) + FormTopMargin

I’ve tried everything to fix it, even replacing all the variables with
actual numbers. When I do that I get a stack overflow error.

In doing some research, I saw that ms had a bug when calculating lng
data types, but that was back in 2001!

What else could I be doing wrong?
Thanks,
alex
 
J

Jeanette Cunningham

Instead of using me.detail.height ,
use Me.Section(acDetail).Height

Instead of using me.FormHeader.height ,
use Me.Section(acHeader).Height

To use Me.sfrm.Height
there must be a subform control called sfrm on the main form.

Use the above in your code to eliminate the error message


You can get a stack overflow error when the total size of your form is too
large.

Make sure the height measurements are all in the same units - twips or
inches (or cemtimetres).
When telling access what height to move to in DoCmd.MoveSize, convert the
height measurements to twips if they are not already in tiwps.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Docmd.Movesize

Hello,

I have the following code that I’ve been using for several months.
It’s used to adjust the size of a form based on the number of records:

---------start code
Private Sub FormResize() 'code to resize both frmMainform and sfrm

Const DetailHeight = 240 'tried using me.detail.height but it didn't
work
'remember that the constant above will depend on how tall your textbox
(s)is
Const FormTopMargin = 560

Dim lngRecordCount As Long
lngRecordCount = Me.sfrm.Form.RecordsetClone.RecordCount '# of records

'form has Header, Detail
DoCmd.MoveSize , , , (DetailHeight * lngRecordCount) _
+ (Me.FormHeader.Height) + FormTopMargin

Me.sfrm.Height = (DetailHeight * lngRecordCount)
'Debug.Print (lngRecordCount)
'Debug.Print (Me.Detail.Height)

End Sub
---------end code

All of a sudden I’m getting this error: An expression you entered is
the wrong data type for one of the arguments (nothing changed, not
even the number of records!).
The debugger goes to this section of code:
DoCmd.MoveSize , , , (DetailHeight * lngRecordCount) _
+ (Me.FormHeader.Height) + FormTopMargin

I’ve tried everything to fix it, even replacing all the variables with
actual numbers. When I do that I get a stack overflow error.

In doing some research, I saw that ms had a bug when calculating lng
data types, but that was back in 2001!

What else could I be doing wrong?
Thanks,
alex
 
A

alex

Hi Alex,

If you cannot get your code to work with Gina's suggestions, you might want
to try this subform resizing method that was posted on the Access Blog
several months ago:

http://blogs.msdn.com/access/archive/2009/09/30/dynamically-resize-a-...

Tom Wickerath
Microsoft Access MVPhttp://www.accessmvp.com/TWickerath/
__________________________________________















- Show quoted text -

Thanks Jeanette,
That seemed to work, although I still need to use the constant for the
detail height...it seems to get confused when I change the record
source of the subform(like it adds and does not reset).

Tom,
I'll definitely check out the db; it's probably a better way than i'm
doing it! If you know where I could find the code without downloading
the db, please let me know.

Thanks again,
alex
 
T

Tom Wickerath

Hi Alex,

I suppose anyone could download the sample, and then copy the code and paste
it into a newsgroup reply. However, I think it would be better for you to
download the sample database to see it in action. If your concern is
downloading from a company-owned PC, then can't you download it using a PC
that you or a friend owns instead?


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________
 
A

alex

Hi Alex,

I suppose anyone could download the sample, and then copy the code and paste
it into a newsgroup reply. However, I think it would be better for you to
download the sample database to see it in action. If your concern is
downloading from a company-owned PC, then can't you download it using a PC
that you or a friend owns instead?

Tom Wickerath
Microsoft Access MVPhttp://www.accessmvp.com/TWickerath/
__________________________________________







- Show quoted text -

Hi Tom,
I checked out the site from home last night...
The db seems to be '07 (which I don't have). Someone else I see asked
for it to be posted in '03 too. I plan on getting '07 in a few days,
however; we'll see.
Thanks for the response.
alex
 
T

Tom Wickerath

Hi Alex,

If you send me a private e-mail message, with a valid reply address, I can
send you a zipped copy of this database converted to the Access 2000 file
format.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________
 

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


Top