Notiophilus
Registered User.
- Local time
- Today, 09:15
- Joined
- Jan 18, 2015
- Messages
- 42
Access 2010. I have a subform which dynamically shows either a form or a report. On the main form there is a button to clear the recordset and filters of each, and for clarity's sake I used a with... end with statement. Access disnae like it.
With the form, this works:
But this doesn't:
This, however, does:
Why? Is this just inconsistency in Access, or might it be a sign of a deeper problem in the code? (For whatever reason, the last statement gave several errors until I changed Report.Filter = "(False)" to .Filter = "", so I don't know if it's just that reports are rather touchy)
With the form, this works:
Code:
If Me.fsubContainer.SourceObject = "fsubBrowseAll" Then
' some stuff here
With Me.fsubContainer.Form
.RecordSource = "tblStory" ' Clear recordsource
.Filter = "(False)" ' and hide ALL records
.FilterOn = True
End With
Code:
ElseIf Me.fsubContainer.SourceObject = "Report.rptStories" Then
With Me.fsubContainer.Report
.RecordSource = "tblStory" ' Clear rs and show all records
[B] [COLOR=Red].Filter = "" ' ##Run-time error 5: invalid procedure or argument[/COLOR][/B]
.FilterOn = True
End With
End If
Code:
Me.fsubContainer.Report.RecordSource = "tblStory"
[COLOR=SeaGreen] [B] Me.fsubContainer.Report.Filter = "" [/B]
[/COLOR] Me.fsubContainer.Report.FilterOn = True