• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 46
  • Last Modified:

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

and

- 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
    Else
        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
0
rogerdjr
Asked:
rogerdjr
2 Solutions
 
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.
1
 
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.
EE.accdb
1
 
rogerdjrAuthor Commented:
Thanks - I'll give this a try.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now