Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: How to Switch a Subform from Datasheet View to Form View


View products that this article applies to.

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.

↑ Back to the top


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.

↑ Back to the top


Keywords: KB216675, kbhowto

↑ Back to the top

Article Info
Article ID : 216675
Revision : 2
Created on : 6/29/2004
Published on : 6/29/2004
Exists online : False
Views : 338