christopherjoubert
New member
- Local time
- Today, 03:21
- Joined
- Jul 14, 2023
- Messages
- 6
I have the following code segment in a vba module for a specific form :
It works perfectly embedding and filtering the report, my issue is I have about 100 options for this code, and if I can avoid copy/paste I'd like to.
So I figured I would create a module that does the exact same thing, I can feed in everything I need, except... When I try this:
I get error 2467 object doesn't exist or is closed
and when I try this:
I get error 2101 the setting you entered is not valid
I am assuming I am just not referencing the main form (frm_MainLanding) or the subreport (srpt_Report) correctly, but I can't seem to find a variation that closes the loop, am I trying to do something that I can't do, or can someone see my mistake?
The debug line that is highlighted is the first line.
Full module :
Code:
Me.srpt_Report.SourceObject = Report
Forms!frm_MainLanding!srpt_Report.Report.filter = Filter
Forms!frm_MainLanding!srpt_Report.Report.FilterOn = True
It works perfectly embedding and filtering the report, my issue is I have about 100 options for this code, and if I can avoid copy/paste I'd like to.
So I figured I would create a module that does the exact same thing, I can feed in everything I need, except... When I try this:
Code:
Forms!frm_MainLanding.srpt_Report.Form.SourceObject = reportname
Forms!frm_MainLanding!srpt_Report.Report.filter = reportfilter
Forms!frm_MainLanding!srpt_Report.Report.FilterOn = True
I get error 2467 object doesn't exist or is closed
and when I try this:
Code:
Forms!frm_MainLanding!srpt_Report.SourceObject = reportname
Forms!frm_MainLanding!srpt_Report.Report.filter = reportfilter
Forms!frm_MainLanding!srpt_Report.Report.FilterOn = True
I get error 2101 the setting you entered is not valid
I am assuming I am just not referencing the main form (frm_MainLanding) or the subreport (srpt_Report) correctly, but I can't seem to find a variation that closes the loop, am I trying to do something that I can't do, or can someone see my mistake?
The debug line that is highlighted is the first line.
Full module :
Code:
Option Compare Database
Option Explicit
Public Sub CallReport(reportname As String, reportfilter As String, Optional searchreport As String)
Forms!frm_MainLanding.srpt_Report.Form.SourceObject = reportname
Forms!frm_MainLanding!srpt_Report.Form.filter = reportfilter
Forms!frm_MainLanding!srpt_Report.Form.FilterOn = True
End Sub
Last edited: