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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change SubForm from FormView to DatasheetView 1

Status
Not open for further replies.

TwoOdd

Programmer
Sep 10, 2003
196
CL
I am wanting to put a button on a main form that will toggle the subform from FormView to DatasheetView and back.

I have found out that the FormView has a value of 1 and DataSheetView has a value of 2, but have not been able to find the syntax to change the CurrentView value in VBA.

It seems like this value is readonly in VBA, can someone confirm that or let me know how to change the CurrentView value in VBA?

Thanks in advance.

TwoOdd
--------------
Good judgment comes from experience, and experience comes from bad judgment.
-- Barry LePatner
 
Okay, I found the answer.
Code:
    Me.[insert subform name here].SetFocus
    If Me.[insert subform name here].Form.CurrentView = 1 Then
        'Current view is FormView - Change to Datasheet
        DoCmd.RunCommand acCmdSubformDatasheet
        'Change the button to read 'Form'
        Me.[insert button name here].Caption = "Form"
    Else
        'Current view is Datshee- Change to Form
        DoCmd.RunCommand acCmdSubformFormView
        'Change the button to read 'Spreadsheet'
        Me.[insert button name here].Caption = "Spreadsheet"
    End If

TwoOdd
--------------
Good judgment comes from experience, and experience comes from bad judgment.
-- Barry LePatner
 
How are ya TwoOdd . . .

Have a look at the [blue]Views Allowed[/blue] property ofa form and the [blue]Views Menu[/blue] when a form is open . . .

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top