Conditional Sub reports

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a main report with 2 sub reports. Is it possible to trigger the 2nd
sub report to only appear when criteria from my table is satisfied? This is a
very simple report, driven only off of 1 table.

For example, if Field Name "status code" = 13, then show sub report 1 and 2,
else just show sub report 1.
 
The LinkMasterFields/LinkChildFields property of the subreport control
should be able to do this for you.

For your example, if the status code field is in the subreport's table, you
would put a text box on the main report, and give it these properties:
Name txtStatusCode
Control Source =13

Then right-click the edge of the subreport control (in report design view),
and choose Properties. If the LinkMasterFields and LinkChildFields already
contain a field (such as ID), add to this property so the fields look like
this:
Link Master Fields ID; txtStatusCode
Link Child Fields ID; [status code]

If the status code field is actually in the main report's table, swap the
logic around. If the condition is actually more complex than a single value,
you can place an expression in the Control Source--an expression that
evaluates to True/False, e.g.:
=(([status code] = 13) OR ([status code] = 1))
and then use a matching text box of:
=-1
since -1 is True in Access. Then use the names of these text boxes in
LinkMasterFields/LinkChildFields.

Of course, adding the criteria to a query would be a much better approach if
that were feasible.
 
Back
Top