ACC2000: How to Switch a Subform from Datasheet View to Form View (216675)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q216675
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

Moderate: Requires basic macro, coding, and interoperability skills.

SUMMARY

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.

MORE INFORMATION

  1. Open the sample database Northwind.
  2. Open the Orders form in Design view.
  3. Add a command button to the main form. If the Command Button Wizard appears, click Cancel.
  4. Set the following properties for the command button:
       Name: cmdChangeView
       Caption: Change View
       OnClick: [Event Procedure]
    					
  5. 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
    					
  6. Close the Visual Basic Editor, and then open the Orders form in Form view.
  7. 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.

Modification Type:MajorLast Reviewed:6/29/2004
Keywords:kbhowto KB216675