a2k - returning the desired records in a subreport - need general help with my approach..

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Deano

    a2k - returning the desired records in a subreport - need general help with my approach..

    OK, I've been taking the detour from hell trying to sort this and after
    taking a walk I think I need a rethink.

    I have a report for a single employee that includes a subreport which lists
    courses taken by that person.

    I ask the user for Start and End dates to allow them to see only courses
    that fall into that date range. I'm then trying to open the report to show
    the current employee with a list of courses that fall within the date range.

    I came up with some SQL that works but I can't assign it to the recordsource
    of the subreport as I intended.

    The only idea I have is to open the main report and filter for the employee
    I want.
    Then I think I need to create a stored query that filters the subreport
    records and make this the subform recordsource. But I'm not sure how to
    create this to include criteria for start and end dates.

    What is the best approach here? Am I on the right lines here? If so any
    tips about creating a suitable stored query?


    Thanks for anyone's suggestions
    Martin



  • Allen Browne

    #2
    Re: a2k - returning the desired records in a subreport - need general help with my approach..

    If you can use a form for the user to enter the limiting dates, you can
    refer to the text boxes on the in the subreport's query.

    For example, the Criteria Row under the CourseDate field might be:
    Between [Forms]![MyForm]![StartDate] And [Forms]![MyForm]![EndDate]

    The other alternative you suggested would also work, i.e. to write the SQL
    property of the QueryDef that the subreport is based on before opening the
    report, e.g.:
    dbEngine(0)(0). QueryDefs("MySu breportQuery"). SQL = "SELECT ...

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Deano" <deanma66999@ho tmail.com> wrote in message
    news:PWWrb.6869 $lm1.48593@ward s.force9.net...[color=blue]
    > OK, I've been taking the detour from hell trying to sort this and after
    > taking a walk I think I need a rethink.
    >
    > I have a report for a single employee that includes a subreport which[/color]
    lists[color=blue]
    > courses taken by that person.
    >
    > I ask the user for Start and End dates to allow them to see only courses
    > that fall into that date range. I'm then trying to open the report to[/color]
    show[color=blue]
    > the current employee with a list of courses that fall within the date[/color]
    range.[color=blue]
    >
    > I came up with some SQL that works but I can't assign it to the[/color]
    recordsource[color=blue]
    > of the subreport as I intended.
    >
    > The only idea I have is to open the main report and filter for the[/color]
    employee[color=blue]
    > I want.
    > Then I think I need to create a stored query that filters the subreport
    > records and make this the subform recordsource. But I'm not sure how to
    > create this to include criteria for start and end dates.
    >
    > What is the best approach here? Am I on the right lines here? If so any
    > tips about creating a suitable stored query?
    >
    >
    > Thanks for anyone's suggestions
    > Martin
    >
    >
    >[/color]


    Comment

    • Deano

      #3
      Re: a2k - returning the desired records in a subreport - need general help with my approach..

      Allen Browne wrote:[color=blue]
      > If you can use a form for the user to enter the limiting dates, you
      > can refer to the text boxes on the in the subreport's query.
      >
      > For example, the Criteria Row under the CourseDate field might be:
      > Between [Forms]![MyForm]![StartDate] And [Forms]![MyForm]![EndDate]
      >
      > The other alternative you suggested would also work, i.e. to write
      > the SQL property of the QueryDef that the subreport is based on
      > before opening the report, e.g.:
      > dbEngine(0)(0). QueryDefs("MySu breportQuery"). SQL = "SELECT ...[/color]

      Allen, you're a godsend. Thanks a million. I used the former method as i
      should have done instead of coming up with increasingly complex strategies.


      Comment

      Working...