Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change form from Form View to Datasheet

Status
Not open for further replies.

mguidry

Technical User
Oct 14, 2004
18
US
I would like to change the view of a form from regular Form View to the Datasheet view with a command button within the form. How do I do this?
 
Private Sub cmdDatasheet_Click()
'***************** Code Start *******************
'This code was originally written by Terry Wickenden.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.

On Error GoTo ErrCmdDatasheet

Me.Log.SetFocus
DoCmd.RunCommand acCmdSubformDatasheet
If Me.cmdDatasheet.Caption = "Datasheet View" Then
Me.cmdDatasheet.Caption = "Form View"
Else
Me.cmdDatasheet.Caption = "Datasheet View"
End If
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

 
Sorry! Posted before looking. Sent sub to change a subforms view. FancyPrarie was right.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top