PC Review


Reply
Thread Tools Rate Thread

Docmd.Movesize

 
 
alex
Guest
Posts: n/a
 
      12th Jan 2010
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
 
Reply With Quote
 
 
 
 
Jeanette Cunningham
Guest
Posts: n/a
 
      13th Jan 2010
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


"alex" <(E-Mail Removed)> wrote in message
news:1bccd1c8-f642-449d-b2fd-(E-Mail Removed)...
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


 
Reply With Quote
 
Tom Wickerath
Guest
Posts: n/a
 
      13th Jan 2010
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...ord-count.aspx


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

"alex" wrote:

> 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
> .
>

 
Reply With Quote
 
alex
Guest
Posts: n/a
 
      13th Jan 2010
On Jan 13, 3:01*am, Tom Wickerath <AOS168b AT comcast DOT net> wrote:
> 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...ally-resize-a-...
>
> Tom Wickerath
> Microsoft Access MVPhttp://www.accessmvp.com/TWickerath/
> __________________________________________
>
>
>
> "alex" wrote:
> > 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
> > .- Hide quoted text -

>
> - 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
 
Reply With Quote
 
Tom Wickerath
Guest
Posts: n/a
 
      14th Jan 2010
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/
__________________________________________

"alex" wrote:

> 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

 
Reply With Quote
 
alex
Guest
Posts: n/a
 
      14th Jan 2010
On Jan 14, 2:33*am, Tom Wickerath <AOS168b AT comcast DOT net> wrote:
> 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/
> __________________________________________
>
>
>
> "alex" wrote:
> > 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- Hide quoted text -

>
> - 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
 
Reply With Quote
 
Tom Wickerath
Guest
Posts: n/a
 
      15th Jan 2010
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/
__________________________________________

"alex" wrote:

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MoveSize Subfrom alex Microsoft Access 2 9th Dec 2009 04:23 PM
DoCmd.MoveSize Chad Microsoft Access Getting Started 2 29th Feb 2008 12:47 PM
How do I write a docmd.MoveSize in Visual Basic in Access? =?Utf-8?B?dHJhaW5lcjA3?= Microsoft Access 0 25th Apr 2007 07:56 PM
Advanced MoveSize =?Utf-8?B?RGF2aWQ=?= Microsoft Access Forms 4 31st Oct 2006 01:16 PM
Movesize problem with .ade Mark A. Sam Microsoft Access VBA Modules 0 20th Jul 2005 12:00 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:52 PM.