How to switch the view of a subform from Datasheet view to Form view
Ivan Guan under Microsoft Office
This article shows you how to switch the view of a subform from Datasheet view to Form view while the main form is open in Form view.
- Open the sample database Northwind.
- Open the Orders form in Design view.
- Add a command button to the main form. If the Command Button Wizard appears, click Cancel.
- Set the following properties for the command button:
Name: cmdChangeView Caption: Change View OnClick: [Event Procedure]
- Set the OnClick property of the command button to the following event procedure:
Private Sub cmdChangeView_Click() Me![Orders Subform].SetFocus DoCmd.RunCommand acCmdSubformDatasheet End Sub - Close the Visual Basic Editor, and then open the Orders form in Form view.
- Click the Change View button to switch the subform from Datasheet view to Form view. Note that the button toggles the subform view. In other words, each time that you click the button, the subform changes either from Datasheet view to Form view, or vice versa.

Add A Comment