Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / June 2004

Tip: Looking for answers? Try searching our database.

How to Obtain the Height of a Form?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kevin Myers - 17 Jun 2004 17:25 GMT
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
Allen Browne - 17 Jun 2004 17:37 GMT
Sum the Height of the sections of the form.

Signature

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.

> 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.
Bri - 17 Jun 2004 18:14 GMT
 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

> How can one obtain obtain the height of a MS Access 2K form?
>
[quoted text clipped - 5 lines]
> Thanks,
> s/KAM
Kevin Myers - 17 Jun 2004 19:14 GMT
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

>   Kevin,
>
[quoted text clipped - 54 lines]
> > Thanks,
> > s/KAM
Allen Browne - 18 Jun 2004 03:02 GMT
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

Signature

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.

> 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:
[quoted text clipped - 18 lines]
> Thanks,
> s/KAM
Kevin Myers - 18 Jun 2004 03:38 GMT
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

> Hi Kevin.
>
[quoted text clipped - 32 lines]
> > Thanks,
> > s/KAM
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.