CLSWL said:
The subreports has don't have ANY relationship to one another except that
they both are apart of the same project.
I can filter the main report. I need to filter the subreport using vb.
Lets say as a user i know task1, task2 and task3 created by joe. I don't
know what projects the tasks are associated with.
Lets also say that ProjectABC has task1 created by joe, task5 created by
mike, and task7 created by mike. Project DEF has task2 created by joe, task3
created by joe and task9 created by mike. ProjectGHI has task21 created by
joe.
As i user, If i select task1, task2 and task3 created by joe, i expect to
see the following:
---ProjectABC----
---Summary-----
-task1 created by joe-
-------------------
---ProjectDEF----
---Summary-----
-task2 created by joe-
-task3 created by joe-
-------------------
Maybe you are still oversimplifying. Not only does your
example output not include a second subreport, it does not
even demonstrate a need for any subreports. That output can
be more easily achieved by using a single report that groups
on the project field. The report's record source query
could be like:
SELECT tblprojects.id,
tbltasks.taskid,
tbltasks.reatedby
FROM tblprojects INNER JOIN tbltasks
ON tbltasks.projectid = tblprojects.id
WHERE . . .
The reason I am not addressing your vba filter idea, is
because, except for Link Master/Child, there is no way to
modify a subreport's record source dataset after the report
begins processing data. Because you must provide the filter
criteria so early, you might as well just build the criteria
into the subreport's record source query. At this point
it's usually easier to review the need for a subreport and
try to find a way to avoid it.
There's still the question of how to filter a query to the
specified tasks. How that could be done depends on what
mechanism you have set up for users to enter/select tasks.
For example, if you have a form with a list box of tasks,
then loop throught the list box's ItemsSelected collection
and concatenate the items to form a string like
:task1:task2:task3: which is stuffed into a hidden text box
on the form. The query's WHERE clause could then be
Forms!theform.thetextbox Like ":" & tbltasks.taskid & ":"