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