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

OpenArgs to Subreport

Status
Not open for further replies.

mwn1218

MIS
Jan 17, 2005
11
US
I have a form where you select multi-certifications of an employee and then run a report to show what they have passed through the use of OpenArgs. That works fine when but the problem I am having is passing the OpenArgs to filter a sub report within the main report. The main report is set up to where you have to enter the employee name in and sub report shows the certifications he has passed. Here is my code to open the report:

Public strFilter as String
Dim varItem As Variant
For Each varItem In Me!lstCertification.ItemsSelected
strFilter = strFilter & ",'" & _
Me![lstCertification].ItemData(varItem) & "'"
Next ' continue loop

If strFilter <> "" Then
strFilter = "[CertID] In (" & Mid(strFilter, 2) & ")"
Else
MsgBox "You did not select any certification(s)."
lstcertification.SetFocus
Exit Sub
End If

DoCmd.OpenReport "rptCertification", acPreview, , , , OpenArgs:=strFilter

On the sub report in the filter property I have tried.
rptCertification.OpenArgs
=strFilter

Neither worked. How do you pass OpenArgs to a sub Report
 
I tried me.rptCertification.OpenArgs (typed in the filter property of the sub report) and all that happened was it came up with a parameter box asking for me.rptCertification.OpenArgs. Does it go in the filter property of the sub report?
 
Could the problem be that the link between the main report and the sub report is the employee and not the certification. There is a employeecertification table and that is where the sub report is pulling from and the main report is pulling from the employee table. Dont knwo if that could cause the problem
 
Not sure offhand mwn1218, I'm not sure if you can use openArgs, on a subform. Maybe it's due to the chain of events that occur, between a main & sub form? Or the fact that maybe a subform is more a control then a form????

A workaround might be to use the filter property of the subreport?

me.rptCertification!subrptName.Form.Filter = strFilter
me.rptCertification!subrptName.Form.FilterOn = True

not sure if the syntax is correct (.Form.)??

 
I tired

Open Event of rptCertification
me.Report.rptCertification!rptProjectSub.Filter = strFilter
me.Report.rptCertification!rptProjectSub.FilterOn = True

and also

Open Event of rptSubProject
me.Report.rptProjectSub.Filter = strFilter
me.Report.rptProjectSub.FilterOn = True

and I get a run-time error '2101': The Setting you entered isn't vaild for this property.

I also tried

In Parent reports Open Event:

Private Sub Report_Open(Cancel As Integer)
If Not IsNull(Me.OpenArgs) Then
Debug.Print Me.OpenArgs
End If
End Sub

In Sub reports Open Event which fires after the Parent reports open event:

Private Sub Report_Open(Cancel As Integer)
If Not IsNull(Me.Parent.OpenArgs) Then
Debug.Print Me.Parent.OpenArgs
End If
End Sub

Filter Property of Sub Report = Me.Parent.OpenArgs

and all i get is a parameter box asking for Me.Parent.OpenArgs.

Thanks again for the help.
 
The OpenArgs property only applies to forms and is read-only once loaded. Aren't you talking about a report? The only thing you can do with a report is set a where condition or filter.

A report can only change its RecordSource in the Report_Open() event, after which it is read-only.

Subforms should be automatically filtered to their master linking field ID. What are the "Link Child Field" and "Link Master Field" settings for the subform?

VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
VBSlammer
From my Object browser (ac2003):
Property OpenArgs As Variant
Membre de Access.Report

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Yup - PHV is correct, openargs for reports, and also windowmode arguement (acDialog;-)), is available in later versions, starting with the 2002 (xp) version.

Changing subreport filter on the fly - I'd follow VBSlammers advice on link master/child fields.

Roy-Vidar
 
PHV - thanks for squaring that one up. I've seen very few people using Access 2003, which I haven't bought. I spent 800 bucks [hammer] on Office XP Developer and my clients want to stick with Access 2000.

VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top