By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,701 Members | 1,955 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,701 IT Pros & Developers. It's quick & easy.

How to Obtain the Height of a Form?

P: n/a
How can one obtain obtain the height of a MS Access 2K form?

There is a width property, but I don't see a corresponding height property.
I need to obtain the height of the form so that I can dynamically resize an
object on the form in the form's Form_Resize method when a user resizes the
form, both horizontally and vertically.

Thanks,
s/KAM

Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Sum the Height of the sections of the form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Kevin Myers" <Ke********@austin.rr.com> wrote in message
news:10*************@corp.supernews.com...
How can one obtain obtain the height of a MS Access 2K form?

There is a width property, but I don't see a corresponding height property. I need to obtain the height of the form so that I can dynamically resize an object on the form in the form's Form_Resize method when a user resizes the form, both horizontally and vertically.

Nov 13 '05 #2

P: n/a
Bri
Kevin,

The total Height of a Form is the sum of the Height of all of the
Sections (Form Header/Footer) and the Detail(s) so there is no one place
for it. If the Height of your headers and footers are contant and you
are not using a continous form then you can add the Detail section to
your header/footer heights. Also, keep in mind that the Height (and
Width) are actualy stored as Twips (1440 twips = 1 inch).

From the Help:

· The Height property applies only to form sections and report sections,
not to forms and reports.
· The Width property applies only to forms and reports, not to form
sections and report sections.
· Both properties apply to controls on forms and reports.

The height of sections and the width of forms and reports are measured
from the inside of their borders.
Air Code
========

For I=0 to 4 '(the five sections of a Form, Report has nine)
lTotalTwips = lTotalTwips + Me.Section(I).Height
Next

Msgbox "The total Height of the Form is: " & _
lTotalTwips /1440 & " Inches"

=========

The Section Properties are read only.

If the object you want to resize is in the Detail Section and you want
it to be a ratio of the Detail Height then:

Air Code
========

'Assume object is to be 50% of the height of the Form Detail Section
Me.MyObject.Height = Me.Section(0).Height / 2

=========

Hope that helps

Bri
Kevin Myers wrote:
How can one obtain obtain the height of a MS Access 2K form?

There is a width property, but I don't see a corresponding height property.
I need to obtain the height of the form so that I can dynamically resize an
object on the form in the form's Form_Resize method when a user resizes the
form, both horizontally and vertically.

Thanks,
s/KAM


Nov 13 '05 #3

P: n/a
Thanks to both Allen and Bri for their very helpful comments. Based on what
they said, here is what I put in the code for my form:

Private Sub Form_Resize()
If (Me.Width / 1440) <= 10 Then ImgEdit1.Width = 4.9167 * 1440 Else
ImgEdit1.Width = Me.Width - 5.0833 * 1440
If (Detail.Height / 1440) <= 7.5 Then ImgEdit1.Height = 7.3333 * 1440 Else
ImgEdit1.Height = Detail.Height - 0.1667 * 1440
End Sub

Unfortunately this still isn't working. The method does seem to be
executing when the form is resized, but the values of Me.Width and
Detail.Height don't seem to be changing. In the properties for the form the
Default View is set to Single Form, Auto Resize is set to No and Border
Style is set to Sizable. In properties for the Detail section, Can Grow and
Can Shrink are both set to Yes, while for the Form Header and Form Footer
sections these properties are both set to No.

What am I overlooking?

Thanks,
s/KAM
"Bri" <no*@here.com> wrote in message
news:DjkAc.752956$Pk3.187813@pd7tw1no...
Kevin,

The total Height of a Form is the sum of the Height of all of the
Sections (Form Header/Footer) and the Detail(s) so there is no one place
for it. If the Height of your headers and footers are contant and you
are not using a continous form then you can add the Detail section to
your header/footer heights. Also, keep in mind that the Height (and
Width) are actualy stored as Twips (1440 twips = 1 inch).

From the Help:

· The Height property applies only to form sections and report sections,
not to forms and reports.
· The Width property applies only to forms and reports, not to form
sections and report sections.
· Both properties apply to controls on forms and reports.

The height of sections and the width of forms and reports are measured
from the inside of their borders.
Air Code
========

For I=0 to 4 '(the five sections of a Form, Report has nine)
lTotalTwips = lTotalTwips + Me.Section(I).Height
Next

Msgbox "The total Height of the Form is: " & _
lTotalTwips /1440 & " Inches"

=========

The Section Properties are read only.

If the object you want to resize is in the Detail Section and you want
it to be a ratio of the Detail Height then:

Air Code
========

'Assume object is to be 50% of the height of the Form Detail Section
Me.MyObject.Height = Me.Section(0).Height / 2

=========

Hope that helps

Bri
Kevin Myers wrote:
How can one obtain obtain the height of a MS Access 2K form?

There is a width property, but I don't see a corresponding height property. I need to obtain the height of the form so that I can dynamically resize an object on the form in the form's Form_Resize method when a user resizes the form, both horizontally and vertically.

Thanks,
s/KAM


Nov 13 '05 #4

P: n/a
Hi Kevin.

Right: if you physically drag the window size such that it is bigger than
the height of of the sections, then the height of the window has no
relationship to the height of the sections.

Stephen Lebans has a free downloadable example showing " a Form that
demonstrates the relationships of the Form and Section Height and Width
properties" in this link:
http://www.lebans.com/formdimensions.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Kevin Myers" <Ke********@austin.rr.com> wrote in message
news:10*************@corp.supernews.com...
Thanks to both Allen and Bri for their very helpful comments. Based on what they said, here is what I put in the code for my form:

Private Sub Form_Resize()
If (Me.Width / 1440) <= 10 Then ImgEdit1.Width = 4.9167 * 1440 Else
ImgEdit1.Width = Me.Width - 5.0833 * 1440
If (Detail.Height / 1440) <= 7.5 Then ImgEdit1.Height = 7.3333 * 1440 Else
ImgEdit1.Height = Detail.Height - 0.1667 * 1440
End Sub

Unfortunately this still isn't working. The method does seem to be
executing when the form is resized, but the values of Me.Width and
Detail.Height don't seem to be changing. In the properties for the form the Default View is set to Single Form, Auto Resize is set to No and Border
Style is set to Sizable. In properties for the Detail section, Can Grow and Can Shrink are both set to Yes, while for the Form Header and Form Footer
sections these properties are both set to No.

What am I overlooking?

Thanks,
s/KAM

Nov 13 '05 #5

P: n/a
Thanks for confirming my observations Allen. After further trial and error,
the following seems to be doing what I want fairly well. I'd appreciate it
if anyone would let me know if they see any obvious pitfalls to this
approach (note that my Form Header and Form Footer sections have a height of
zero):

Private Sub Form_Resize()
Me.Width = Me.InsideWidth - 0.25 * 1440
Detail.Height = Me.InsideHeight - 0.25 * 1440
If (Me.Width / 1440) <= 10 Then ImgEdit1.Width = 4.9167 * 1440 Else
ImgEdit1.Width = Me.Width - 5.0833 * 1440
If (Detail.Height / 1440) <= 7.5 Then ImgEdit1.Height = 7.3333 * 1440 Else
ImgEdit1.Height = Detail.Height - 0.1667 * 1440
ImgEdit1.FitTo 1
End Sub
Regards,
s/KAM


"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:40***********************@per-qv1-newsreader-01.iinet.net.au...
Hi Kevin.

Right: if you physically drag the window size such that it is bigger than
the height of of the sections, then the height of the window has no
relationship to the height of the sections.

Stephen Lebans has a free downloadable example showing " a Form that
demonstrates the relationships of the Form and Section Height and Width
properties" in this link:
http://www.lebans.com/formdimensions.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Kevin Myers" <Ke********@austin.rr.com> wrote in message
news:10*************@corp.supernews.com...
Thanks to both Allen and Bri for their very helpful comments. Based on

what
they said, here is what I put in the code for my form:

Private Sub Form_Resize()
If (Me.Width / 1440) <= 10 Then ImgEdit1.Width = 4.9167 * 1440 Else
ImgEdit1.Width = Me.Width - 5.0833 * 1440
If (Detail.Height / 1440) <= 7.5 Then ImgEdit1.Height = 7.3333 * 1440 Else ImgEdit1.Height = Detail.Height - 0.1667 * 1440
End Sub

Unfortunately this still isn't working. The method does seem to be
executing when the form is resized, but the values of Me.Width and
Detail.Height don't seem to be changing. In the properties for the form

the
Default View is set to Single Form, Auto Resize is set to No and Border
Style is set to Sizable. In properties for the Detail section, Can Grow

and
Can Shrink are both set to Yes, while for the Form Header and Form Footer sections these properties are both set to No.

What am I overlooking?

Thanks,
s/KAM


Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.