Results 1 to 11 of 11
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Detail height continuous form not shrinking

    If I have only 3 records in a continuous form I expect the "can shrink" to shrink however the height of the form extends further than I require.



    Popup setting to yes

    Is there a way of shrinking it automatically to the height of the 3 records?

    Note: detail section of the form as a whole, not each record (they are all shrunk and row height is short)

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by Ruegen View Post

    ...If I have only 3 records in a continuous form I expect the "can shrink" to shrink...
    The CanGrow/CanShrink Properties always applies to Reports, but only applies to Forms when they are being printed, not when they are being viewed.

    Quote Originally Posted by Ruegen View Post

    ...Is there a way of shrinking it automatically to the height of the 3 records...
    No, there is not a way to 'automatically' shrink the Detail Section. This would have to be done using code, probably rather complicated code. In general, the process would involve

    1. Determining the Height of a single Record
    2. Determining how many Records you have to display
    3. Programmatically setting the Height of the Detail Section, based on multiplying #1 X #2

    I have never used it, but Stephen Lebans has a hack that gives Forms that are being displayed the same CanGrow/CanShrink functionality as is available on Reports; hopefully this will be of help to you, either addressing the problem directly, or at least pointing the way. The hack can be downloaded from here:

    http://www.lebans.com/cangrow.htm

    Linq ;0)>

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by Missinglinq View Post
    The CanGrow/CanShrink Properties always applies to Reports, but only applies to Forms when they are being printed, not when they are being viewed.



    No, there is not a way to 'automatically' shrink the Detail Section. This would have to be done using code, probably rather complicated code. In general, the process would involve

    1. Determining the Height of a single Record
    2. Determining how many Records you have to display
    3. Programmatically setting the Height of the Detail Section, based on multiplying #1 X #2

    I have never used it, but Stephen Lebans has a hack that gives Forms that are being displayed the same CanGrow/CanShrink functionality as is available on Reports; hopefully this will be of help to you, either addressing the problem directly, or at least pointing the way. The hack can be downloaded from here:

    http://www.lebans.com/cangrow.htm

    Linq ;0)>

    I've done this sort of thing with reports (if they have data over a certain value)

    does the form have a height? I understand each record has a height and detail is each record and not as a whole?

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by Ruegen View Post

    ...does the form have a height...
    Forms do not have a Height Property, only Width.

    Each Section (Header, Detail and Footer) has its own Height Property, so you could calculate the Form's 'height' from these, if you needed to.

    Quote Originally Posted by Ruegen View Post

    ...I understand each record has a height and detail is each record and not as a whole...
    To be honest, I'm not exactly sure about what you're asking, here. From a practical standpoint, on a Single View Form the Height of the Detail Section would also be the 'height' of a Record. But on Datasheet View and Continuous View Forms this would not be true. On these types of Forms you'd have to do some experimenting to find out a Record's 'height.' For you current three Records, I'd set the Detail Section Height to, say, 3 Inches, run the Form, and see what it looks like. If you cannot see all three Records, in their entirety, increase the Detail Section Height to, say, 3.6 Inches, run the Form again, observe the results and adjust the Detail Section Height again, repeating until it looks as you want it to. Then divide the Detail Section Height by the number of Records (three, in this case) to get the Record 'height.'

    Then, to dynamically set the Detail Section Height for the current number of Records, when the Form opens you'd get a Record Count, multiply by the number of Records by the Record 'height' and set the Detail Section Height to this figure.

    Tweaking something like this is likely to be more work than I'd be willing to give it, in most circumstances! We all like our apps to look nice, but we are, after all, talking about a Database, not a Graphics program nor a webpage, but a business app. Of course, that's a matter of taste, and I'm a true believer in the philosophy of 'to each his own!'.

    Linq ;0)>

  5. #5
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by Missinglinq View Post
    Forms do not have a Height Property, only Width.

    Each Section (Header, Detail and Footer) has its own Height Property, so you could calculate the Form's 'height' from these, if you needed to.


    To be honest, I'm not exactly sure about what you're asking, here. From a practical standpoint, on a Single View Form the Height of the Detail Section would also be the 'height' of a Record. But on Datasheet View and Continuous View Forms this would not be true. On these types of Forms you'd have to do some experimenting to find out a Record's 'height.' For you current three Records, I'd set the Detail Section Height to, say, 3 Inches, run the Form, and see what it looks like. If you cannot see all three Records, in their entirety, increase the Detail Section Height to, say, 3.6 Inches, run the Form again, observe the results and adjust the Detail Section Height again, repeating until it looks as you want it to. Then divide the Detail Section Height by the number of Records (three, in this case) to get the Record 'height.'

    Then, to dynamically set the Detail Section Height for the current number of Records, when the Form opens you'd get a Record Count, multiply by the number of Records by the Record 'height' and set the Detail Section Height to this figure.

    Tweaking something like this is likely to be more work than I'd be willing to give it, in most circumstances! We all like our apps to look nice, but we are, after all, talking about a Database, not a Graphics program nor a webpage, but a business app. Of course, that's a matter of taste, and I'm a true believer in the philosophy of 'to each his own!'.

    Linq ;0)>

    I've uploaded an example

    as you can see the rows don't go down all the way however the form does.

    Click image for larger version. 

Name:	Capture.PNG 
Views:	10 
Size:	22.1 KB 
ID:	17812

  6. #6
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    on a form load I can get the full height this way

    Code:
    Debug.Print Me.detail.Height
    Debug.Print Me.FormHeader.Height
    
    
    Dim lngDetailSum As Long
    
    
    If Me.Recordset.RecordCount <= 0 Then
    Else
    For CountDetail = 1 To Me.Recordset.RecordCount
    lngDetailSum = lngDetailSum + Me.detail.Height
    Next
    End If
    Debug.Print lngDetailSum + Me.FormHeader.Height & " result"
    now to modify the complete form...

  7. #7
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    since form doesn't have height I can't edit the height of the pop up form :-/

  8. #8
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    I'm wondering if I need to do this

    http://www.access-programmers.co.uk/...d.php?t=172827

  9. #9
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    This works[code]Private Sub Form_Load()Debug.Print Me.detail.HeightDebug.Print Me.FormHeader.HeightDim lngDetailSum As LongDebug.Print Me.Form.Width & "width"If Me.Recordset.RecordCount

  10. #10
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    This works
    Code:
    Private Sub Form_Load()
    Debug.Print Me.detail.Height
    Debug.Print Me.FormHeader.Height
    
    
    Dim lngDetailSum As Long
    Debug.Print Me.Form.Width & "width"
    If Me.Recordset.RecordCount <= 0 Then
    Else
    For CountDetail = 0 To Me.Recordset.RecordCount
    lngDetailSum = lngDetailSum + Me.detail.Height
    Next
    If lngDetailSum >= 20000 Then
    Else
    lngDetailSum = lngDetailSum + Me.FormHeader.Height + 700
    
    
    Debug.Print lngDetailSum + Me.FormHeader.Height & " result"
    DoCmd.MoveSize , , Me.Form.Width + 1000, lngDetailSum
    End If
    End If
    
    
    
    
    End Sub

  11. #11
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Code:
    Public Sub ResizeContinuousForm(Detail_Height As Long, Form_Header_Height As Long, Form_RecordSetCount As Long, Form_Width As Long)
    
    
    Dim lngDetailSum As Long, CountDetail As Long
    If Form_RecordSetCount <= 0 Then
    
    
    Exit Sub
    
    
        Else
        
        For CountDetail = 0 To Form_RecordSetCount
            lngDetailSum = lngDetailSum + Detail_Height
        Next
        
            If lngDetailSum >= 20000 Then
            Else
                lngDetailSum = lngDetailSum + Form_Header_Height + 900
                
                DoCmd.MoveSize , , Form_Width + 1000, lngDetailSum
            End If
    End If
    
    
    End Sub
    as a sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. form with expanding/shrinking sub-forms?
    By benjammin in forum Forms
    Replies: 19
    Last Post: 02-02-2015, 02:52 PM
  2. height of Detail section in reports
    By Nicola in forum Reports
    Replies: 4
    Last Post: 05-31-2013, 02:46 AM
  3. Change Height of Box to height of textBox
    By oxicottin in forum Reports
    Replies: 7
    Last Post: 03-15-2013, 09:54 PM
  4. Replies: 4
    Last Post: 09-15-2012, 07:31 PM
  5. set continuous form height
    By taylorosso in forum Forms
    Replies: 0
    Last Post: 08-31-2009, 05:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums