Change Form View
acCmdDatasheetView
This example changes a form to Datasheet view. It will only work if the form's Views Allowed property is set to both. The code is behind a button called cmdDatasheet. However this button will disappear when you change to Datasheet View as will any other button.
If you require an example for a SubForm have a look at acCmdSubformDatasheet.
'***************** Code Start *******************
'Original code by Terry Wickenden
Private Sub cmdDatasheet_Click()
On Error GoTo ErrCmdDatasheet
DoCmd.RunCommand acCmdDatasheetView
Exit Sub
ErrCmdDatasheet:
Select Case Err
Case 2046
'Datasheet view not available
MsgBox "This command not available at this time"
Exit Sub
Case Else
MsgBox Err.Number & vbCrLf & Err.Description
Exit Sub
End Select
End Sub
'****************** Code End ********************