Results 1 to 9 of 9
  1. #1
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434

    autoresize subform height

    hi, i'm using this function to autoresize a subform that has only detail section
    Code:
    Function ResizeSubForm(SubFrm As SubForm)    
       Dim rs As DAO.Recordset
       Dim RecordCnt As Integer
       Set rs = SubFrm.Form.RecordsetClone
       RecordCnt = rs.RecordCount
       SubFrm.Height = SubFrm.Section(0).Height * (RecordCnt)
    End Function
    it returns me "wrong number of arguments or property assignation not valid.




    i tried too with "subfrm.section(AcDetail)

    thoughts?

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    Height property applies only to form sections, not the form itself. Try applying your height value to the detail section if there is no header or footer.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434
    i tried to set from the main form the height of subform and it worked

    Code:
    me.partecipanti.height = 200
    then i tried what you said (at least what i get)

    Code:
     Me.Partecipanti.Height = Me.Partecipanti.Section(0).Height
    and got the same error

    ps my goal is to resize the height of subform based of number of records

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    I'm guessing that partecipanti is the name of your subform control, not the name of your subform? These are not the same thing. If that is incorrect then I don't know what you're doing or what you have. If height is not a form property (and M$ says it is not) then you can't refer to a property that doesn't exist no matter how you write it:
    Me.Partecipanti.Height

    would be invalid if partecipanti is a form. If that is the subform control, you should be able to increase its height, but the subform itself likely won't increase in height to match it.
    I think you need to identify the names of your subform control and the subform itself.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434
    thanks! that was the point, i'd never understand by myself

    just i had to change " SubFrm.Height = SubFrm.Section(0).Height * (RecordCnt)" to SubFrm.Height = SubFrm.Form.Section(0).Height * (RecordCnt)

    and everything is fine!!

  6. #6
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    Still don't know what your objects are named, but it looks like SubFrm is the subform control, which you've declared as a subform rather than a Control, which kind of surprises me that the code works. Anyway, glad to have been able to help in some small way.
    Thanks for the rep point.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434
    My subform Is named "partecipanti" so in the argument of the function i out "me.partecipanti"

    The part "subfrm.height" Is referred to the control, the "subfrm.form.section" Is referred to the form, that's my interpretation.

    Actually, subfrm Is a subform and not a control but you know, It Is like love, noone knows how It works but It works

  8. #8
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Don't know what your code look like now, but you should close and destroy the recordset when done with it:
    Code:
    Function ResizeSubForm(SubFrm As SubForm)    
        Dim rs As DAO.Recordset
        Dim RecordCnt As Integer
       
        Set rs = SubFrm.Form.RecordsetClone
        RecordCnt = rs.RecordCount
        If RecordCnt>0 Then
            SubFrm.Height = SubFrm.Section(0).Height * (RecordCnt)
        End If
        
        rs.Close
        Set rs = Nothing
    End Function

  9. #9
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434
    sure, i always forgot and then in my pc there are 40 recordset buzzing around

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

Similar Threads

  1. Replies: 2
    Last Post: 02-28-2018, 05:04 PM
  2. Replies: 4
    Last Post: 04-18-2017, 12:19 PM
  3. How to set overall report height?
    By mcusuma1 in forum Reports
    Replies: 3
    Last Post: 06-11-2015, 09:49 AM
  4. Change Height of Box to height of textBox
    By oxicottin in forum Reports
    Replies: 7
    Last Post: 03-15-2013, 09:54 PM
  5. Replies: 4
    Last Post: 09-15-2012, 07:31 PM

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