Trying to toggle a subform between continuous and single view

I have an access subform that I would like to switch between:

- Continuous with no footer visible


- single form with footer visible

I added a toggle button in the parent form with the following code

Private Sub Toggle441_Click()
    Dim FormFilter As String
    FormFilter = Forms![0_masterdatafrm]![01_WkgSubmtlContrSbmtlSchFrm].Form.Filter
    If Me![Toggle440].Value = -1 Then
        Me![Toggle440].Caption = "Switch to Continuous View"
        Forms![0_masterdatafrm]![01_WkgSubmtlContrSbmtlSchFrm].Form.View = 1
        Forms![0_masterdatafrm]![01_WkgSubmtlContrSbmtlSchFrm].Form.FormFooter.Visible = 0
        Forms![0_masterdatafrm]![01_WkgSubmtlContrSbmtlSchFrm].Form.Filter = FormFilter
        Forms![0_masterdatafrm]![01_WkgSubmtlContrSbmtlSchFrm].Form.FilterOn = -1
        Me![Toggle440].Caption = "Switch to Single Form View"

        Forms![0_masterdatafrm]![01_WkgSubmtlContrSbmtlSchFrm].Form.View = 0
        Forms![0_masterdatafrm]![01_WkgSubmtlContrSbmtlSchFrm].Form.FormFooter.Visible = -1
        Forms![0_masterdatafrm]![01_WkgSubmtlContrSbmtlSchFrm].Form.Filter = FormFilter
        Forms![0_masterdatafrm]![01_WkgSubmtlContrSbmtlSchFrm].Form.FilterOn = -1

    End If

End Sub

Open in new window

But when I click the button I get an error message 2465 "application-defined or object-defined error"

Any ideas how to do this would be appreciated
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
I don't think that is possible.
I would create two subforms, then set the toggle button to hide one or the other. Much simpler.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fabrice LambertFabrice LambertCommented:
You can achieve this with a sub form:

Create a main form.
Create 2 sub forms, one is continuous, the other is not.
Give a meaningfull name to the subForm control.
With VBA, change the SourceObject property.

Sample attached below.
rogerdjrAuthor Commented:
Thanks - I'll give this a try.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.