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