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 2 / September 2007

Tip: Looking for answers? Try searching our database.

Subform Setting

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chipcom - 15 Sep 2007 05:49 GMT
Hi

I would like to know how to cause that the subform can not be on
focus?
I would like to know how to shrink and grow automatically?

Thanks
Steve Schapel - 15 Sep 2007 20:51 GMT
Chipcom,

To prevent access to the subform, set the Enabled property of the
subform to No.

As for shrinking and growing, I assume you mean a continuous view
subform whose height is adjusted according to the number of records.  Is
that right?  If so, you would need to write some VBA code to change the
height of the subform control, to a value that is calculated by
multiplying the number of records by the height of the Detail section of
the subform.  If there were controls on the form which are underneath
the subform, and you wnat also that their position is adjusted according
to the height of the subform, then this would require more code to
adjust the value of their Top property.  It can be done.  The code would
probably need to run on the Current event of the main form.

Signature

Steve Schapel, Microsoft Access MVP

> Hi
>
[quoted text clipped - 3 lines]
>
> Thanks
Chipcom - 17 Sep 2007 06:04 GMT
> Chipcom,
>
[quoted text clipped - 24 lines]
>
> - Show quoted text -

Can you please show me an example how to write a code to adjust the
height of the subform (The subform view is datasheet)?

You said : "set the Enabled property of the subform to No" - But what
is the Enabled property?

Thanks
Steve Schapel - 18 Sep 2007 18:59 GMT
Chipcom,

Re the Enabled property... In the design view of the main form, select
the subform, and then open the Property sheet.  You will see the Enabled
property listed, with possible settings being Yes or No.

Sample code:

    Dim subHeight As Long
    Dim subRecords As Integer
    subRecords = DCount("*", "YourQuery") + 1
    subHeight = Int(((0.58 * subRecords) + 1) * 567)
    If subHeight > 7655 Then
        subHeight = 7655
    End If
    Me.YourSubformName.Height = subHeight

In this example:
YourQuery = then name of the query that the subform is based on.
0.58 = the height of the Detail section of the subform in centimetres.
567 = the number of twips in a centimetre.
7655 = the maximum height (in twips) for the subform.
YourSubformName is the actual name of the subform control.

I would recommend using a continuous view form for the subform, rather
than datasheet.

Signature

Steve Schapel, Microsoft Access MVP

> Can you please show me an example how to write a code to adjust the
> height of the subform (The subform view is datasheet)?
>
> You said : "set the Enabled property of the subform to No" - But what
> is the Enabled property?
 
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



©2009 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.