Changing View from From to Datasheet in VBA

J

jake

My customers do not like using the View menu to change between the
Form and Datasheet view in Access.

Is there a way to trap keys (like HOME and END) to switch between
formats?

I tried to following but got an error "You can't change to a different
view at this time!"

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If (KeyCode = 36) Then ' pressed HOME
DoCmd.RunCommand acCmdFormView
End If
If (KeyCode = 35) Then ' pressed END
DoCmd.RunCommand acCmdDatasheetView
End If
End Sub
 
Top