Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expand Datasheet Subform

Status
Not open for further replies.

dlene

IS-IT--Management
Mar 29, 2005
11
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?

 
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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top