Parent (Single) Form Resize to fit Dynamic (Continuous) SubForm?

Unfortunately my searches didn’t bring me much luck so I’m resorting to my fellow redditors for some assistance. I am looking to resize the parent form’s detail section to fit the size of the subform control without using any scrollbars.

Basically, I have a subform (sfrmEmployeeAttendanceSummary) continuous form that lists the total hours for each absence codes used for an individual in the current month. While there are many codes that may be used, it is unlikely it would exceed more than 5 different codes in a single month for that individual. I was able to get this subform to dynamically change size depending on the number of records listed using the code below in the parent form’s (frmEmployeeAttendanceSummary) current event code.

Parent Form’s Current Event Code:

Private Sub Form_Current() With Me.sfrmEmployeeAttendanceSummary .Height = .Form.Section(1).Height + .Form.Section(2).Height + (.Form.Section(0).Height * (.Form.Recordset.recordcount + 1)) End With End Sub 

Now, what I need done is to dynamically resize the detail section of the parent form to fit the dynamically changing subform. Here is the parent form’s design and properties and here is how it looks when loaded. I do not want scroll bars for aesthetic reasons and purely because it’s unnecessary with the number of records that would be available under any normal situation.

I assume, logically, that I would probably grab the size of the subform after it has been dynamically changed then set the detail section(0) of the parent to that specific size in addition to the parent form’s header and footer section in a fashion similar to the code I included above.

Any kind of guidance on how I can accomplish this would be appreciated.


Edit: The parent form is a pop-up form.

submitted by /u/OR-BBurton
[link] [comments]

Posted on