An Aesthetic Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Occasionally, I will use forms that contain data in rows. The number of rows
in a given form may vary from time to time depending on how many topics I
include on the form.

Is there a way to adjust the height of the form with code so that it is just
big enough to hold the amount of information I place into it each time it
opens? This is what I've tried so far (coding in a module apart from the
form):

dim h as integer
h = 1

For x = 0 to numTopics - 1
h = h + .4167
Forms!Checks!Detail.Height = h
Next

No luck. Any other suggestions? As always, thank you in advance.
 
Sections don't have an InsideHeight property (though forms do). But you
should be able to do what you want with the Height property of the section.
Here's a quick demo ...

Private Sub Command0_Click()

If Me.Section(0).Height <= 1701 Then
Me.Section(0).Height = Me.Section(0).Height * 2
Else
Me.Section(0).Height = 1701
End If
DoCmd.SelectObject acForm, Me.Name, False
DoCmd.RunCommand acCmdSizeToFitForm

End Sub

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Joe said:
Occasionally, I will use forms that contain data in rows. The number
of rows in a given form may vary from time to time depending on how
many topics I include on the form.

Is there a way to adjust the height of the form with code so that it
is just big enough to hold the amount of information I place into it
each time it opens? This is what I've tried so far (coding in a
module apart from the form):

dim h as integer
h = 1

For x = 0 to numTopics - 1
h = h + .4167
Forms!Checks!Detail.Height = h
Next

No luck. Any other suggestions? As always, thank you in advance.

Maybe it's partly because height and width properties must be set in VBA
using twips, not inches or centimeters. 1 twip = 1/1440 inch.

And I think it's also going to be the case that you don't want to
increase the height of the Detail section. These are continuous forms,
right? Then I think increasing the height of the Detail section will
increase it for each row, which is not what you want, I think.

Try this:

Dim lngNRows As Long
Dim lngNewHeight As Long

With Me.RecordsetClone
.MoveLast
lngNRows = .RecordCount
End With

' If you want to allow for the blank row, add 1 to lngNRows here.

lngNewHeight = (lngNRows * Me.Detail.Height)

With Me.FormHeader
If .Visible Then lngNewHeight = lngNewHeight + .Height
End With

With Me.FormFooter
If .Visible Then lngNewHeight = lngNewHeight + .Height
End With

Me.InsideHeight = lngNewHeight
 
InsideHeight is a form property property, not a section
property.

The way I do this kind of thing is

If numTopics > 10 Then numTopics = 10
Me.InsideHeight = Me.Section(1).Height _
+ Me.Section(2).Height _
+ numTopics * Me.Section(0).Height

If the form does not have the header/footer sections, then
leave that part out of the expression.
 
Back
Top