Code Examples For RunCommand Constants

Change the Display of a Subform

acCmdSubformDatasheetView, acCmdSubformFormView

This code was posted by the Access MVP Brendan Reymolds on the microsoft.public.access newsgroup.

'***************** Code Start *******************
Private Sub Command1_Click()

   Me.NameOfSubformControl.SetFocus

   '1 = form view, 2 = datasheet view ...
   If Me.NameOfSubformControl.Form.CurrentView = 1 Then
     DoCmd.RunCommand acCmdSubformDatasheetView<\strong>
   Else
   DoCmd.RunCommand acCmdSubformFormView<\strong>
   End If

End Sub
'****************** Code End ********************