Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

supress detail and subreport if no data present

Status
Not open for further replies.

stevesd

Technical User
Dec 26, 2000
74
US
I need to suppress printing the main and the subreport unless there is data in my subreport line. If there is data in the subreport, in other words, that's the only time I want to show both.
 
You are going to have some trouble with that because the main report fires before the subreport, and it won't know yet whether there is going to be any data for the subreport.

You can restrict the data coming into the report by linking the datasource for the main report to the datasource for the subreport within a query

Example:

ParentTable (report datasource)
ParentID ParentName
101 Bill
102 Nancy
103 Helen


ChildTable (subreport datasource)
ChildID ParentID Name
201 101 Bill, Jr.
202 101 Carrie
203 103 Jamie
204 103 Tina


Use this as the datasource for the main report:
Select ParentID, ParentName
From ParentTable
Inner Join ChildTable
On ParentTable.ParentID = ChildTable.ParentID

Use this as the datasource for the subreport:
Select ParentID, ChildName
From ChildTable

Link the reports on the ParentID

Nancy will never appear on the report because she has no children. I am sure your situation is not so basic but you may be able to apply the same principle.

 
Thanks lynchg for your speedy reply. I have tried one change that seemed to make sense: I have formatted the detail line of the subreport conditionally. That is I found a field in the detail line, and wrote, 'if isnull({cust.acct}) then true, else false' I hope that will suppress the sub report lines when there is nothing there. I can deal with the report if there are detail and subreport lines both. That job is running so, we'll see.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top