Nov 30, 2005 #1 dlene IS-IT--Management Joined Mar 29, 2005 Messages 11 Location US I have a form with a datasheet subform. I need the datasheet to automatically expand to the number of records in it. If this can't be done, what options do I have?
I have a form with a datasheet subform. I need the datasheet to automatically expand to the number of records in it. If this can't be done, what options do I have?
Nov 30, 2005 #2 BoxHead Technical User Joined May 6, 2001 Messages 876 Location US Not knowing the structure, I can only answer with an example. I have a form with a subform. Linked on the CustID field. The subform's recordsource is 'query22'. I use a DCount statement to get the number of records that will be returned in the subform for each record in the main form. I set a variable for the height of a single row oneRow and use that to adjust the subform height on the main form's current event. Code: Private Sub Form_Current() oneRow = 0.2 * 1440 tblOrder_subform.Height = (3 * oneRow) + (oneRow * (DCount("*", "query22", "[CustID] = '" & Form_frmC2.CustId & "'")) - 1) End Sub I use the '3 * oneRow' to make sure that the column names, the record selectors and the empty new record field are always visible. Play around with the height variable until you get a consistent, acceptable look. HTH Upvote 0 Downvote
Not knowing the structure, I can only answer with an example. I have a form with a subform. Linked on the CustID field. The subform's recordsource is 'query22'. I use a DCount statement to get the number of records that will be returned in the subform for each record in the main form. I set a variable for the height of a single row oneRow and use that to adjust the subform height on the main form's current event. Code: Private Sub Form_Current() oneRow = 0.2 * 1440 tblOrder_subform.Height = (3 * oneRow) + (oneRow * (DCount("*", "query22", "[CustID] = '" & Form_frmC2.CustId & "'")) - 1) End Sub I use the '3 * oneRow' to make sure that the column names, the record selectors and the empty new record field are always visible. Play around with the height variable until you get a consistent, acceptable look. HTH