Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Oct 2003
    Location
    Long Beach, California, USA
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open a rpt & sub rpt using alternate query (2002 SP2)

    Hi,
    I have a report1 that has a subreport1 in it. Both reports use query1 as their source. I added a button to open report1 using query2. I'm coding it with docmd.openreport "report1", acViewPreview, "query2". It opens fine and the report1 uses query2. However subreport1 is still using query1. How do I get both to use query2? Thank you.
    Ryan

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open a rpt & sub rpt using alternate query (2002 SP2)

    If both main report and subreport use the same query as record source, why have a subreport at all?

    By the way, you're not really setting the record source of the main report to Query2; you're using the WHERE part of Query2 as filter.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Open a rpt & sub rpt using alternate query (2002 SP2)

    From the line you posted, you aren't changing the recordsource of the report/subreport, you're changing the filter of the report. In that case, if your subreport is properly linked to the parent report, you shouldn't have to do anything because the master/child links between the parent and child reports will take care of filtering the subreport. If you provide more information, someone should be able to help you work out the details.
    Charlotte

  4. #4
    New Lounger
    Join Date
    Oct 2003
    Location
    Long Beach, California, USA
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open a rpt & sub rpt using alternate query (2002 SP2)

    Hans,

    Thanks for the reply.

    I have 2 groups of sections from that query that has to be displayed & group separately. I have to display, say, 5 lines of section one followed by 5 lines of section two for a particular item, then move on to the next item. If I put them all in the detail line, it will display line 1 section one, line 1 section two, line 2 section one, line 2 section two, etc. So, I put info for section two on a subreport, and put that subreport under the group footer section of the report containing section one. Hope I'm not making it more confusing.

    I even try manually changing the record source under property and then run the report, but the subreport still looking at the original query. My alternative is to copy the original report/subreport and point them to the new query, but I'm trying to avoid that because I have many of these reports.

    Ryan

  5. #5
    New Lounger
    Join Date
    Oct 2003
    Location
    Long Beach, California, USA
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open a rpt & sub rpt using alternate query (2002 SP2)

    Thank you for your reply, Charlotte.
    Ryan

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open a rpt & sub rpt using alternate query (2002 SP2)

    Hello Ryan,

    What you describe is typically what you would do using the Sorting and Grouping window in the main report, without using a subreport. If that doesn't come out the way you want, that makes me think you haven't set up sorting and grouping entirely correctly. Do you have a sorting/grouping level above section? Check this carefully, and if you can't find what's wrong, report what you have in the Sorting and Grouping window.

    I don't think that what you're trying to achieve is possible using subreports. Changing the filter or the record source of the subreport in code doesn't work.

Posting Permissions

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