Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Jun 2004
    Location
    Lambertville, New Jersey, USA
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have sub-report that needs to change it's record source based upon values in the parent report. This sub report is used in multiple main reports so I can't reference the control directly since I would have to specify the Main report name. I am trying to use the Me.Parent!ControlName syntex in the RecordSource query of the subreport but it isn't working. Simply stated: I need to make the RecordSource of the subreport generic so I can use the subreport in multiple main reports.

    Any suggestions would be greatly appreciated.

    Thanks.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    The keyword Me can only be used in VBA code, not in expressions or in queries. Can't you use the Link Child Fields and Link Master Fields properties of the subreport as a control on the main report?

  3. #3
    Star Lounger
    Join Date
    Jun 2004
    Location
    Lambertville, New Jersey, USA
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've already linked Master and Child fields where appropriate. There are several sub reports on this particular report. I can't use them in all sub-reports because some have criteria such as: "<= MainReport!Testdate" so a direct link is not possible. I can reference the Main Report fields directly in the query but then I will have to create seperate subreports for each main report that uses them. I was hoping to create a generic RecordSource / query string so I could use them in any report I need.

    Hans;

    Is it possible to set the recordsource property outside of the object itself - without it being open?

    i.e. Reports!SubRptName.Recordsource = strSQL

    In the preceeding syntex the SubRptName report must be open to appear in the Reports collection - yes? Is there anyway to set the recordsource while the object is closed?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You could use the On Open event of the subreport to set the RecordSource property to a SQL string.

  5. #5
    Star Lounger
    Join Date
    Jun 2004
    Location
    Lambertville, New Jersey, USA
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's exactly what I'm trying right now. Great minds think alike

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •