SubdatasheetExpanded Property

Microsoft Access Visual Basic

expression.SubdatasheetExpanded

expression    Required. An expression that returns one of the objects in the Applies To list.

Remarks

The SubdatasheetExpanded property uses the following settings.

Setting Visual Basic Description
Yes True The saved state of all subdatasheets in the table is expanded.
No False (Default) The saved state of all subdatasheets in the table is closed.

Note  The easiest way to set the SubdatasheetExpanded property is by using a table's property sheet. You can set this property by using Visual Basic.

To set the SubdatasheetExpanded property by using Visual Basic, you must first either:

The value of the SubdatasheetExpanded property is displayed in the Table Properties property sheet.

The SubdatasheetExpanded and SubdatasheetHeight properties take effect on the subform control when the form is in datasheet view.

Example

The following example turns subdatasheet expansion on or off for the "Purchase Orders" form.

Dim strExpand As String

With Forms("Purchase Orders")
    
    strExpand = InputBox("Expand subdatasheets? Y/N")
    
    Select Case strExpand
        Case "Y"
            .SubdatasheetExpanded = True
        Case "N"
            .SubdatasheetExpanded = False
        Case Else
            MsgBox "Can't determine subdatasheet expansion state."
    End Select

End With
		

To try this example yourself, open a form (containing a subform) in Design view, click the Builder button next to the On Load property box in the form's property window, paste this code into the form's Form_Load event (removing the reference to the "Purchase Orders" form), and then open the form in Datasheet view.