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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Subreport w/ no data to show in Main Report

Status
Not open for further replies.

jwashing2

Programmer
Mar 26, 2005
3
US
I have a problem. I have a main report that holds two subreports. The first report is a summary of violations from the second report. The second report is a full listing of login attempts.

I need help with making the reports - complete with headers and footers - to show in the main report even if no data is found.

The process is this: my database populates a table with a full listing of logon attempts. Then it extracts actual violations into a separate table. My Main report pulls two reports together: Violation Summary & Logon Failures. These reports may or may not have data.

I have to show these two reports as one Main report. Both have separate headings and separate counters that must be displayed, and I need to ensure that the 'Page of Pages' in the Main report footer numbers both reports together. Then I will export the Main report to a directory as a .snp file.

Is there a way to make this happen or is there a known work around for generating two separate reports while passing the total page numbers to display a joined footer field 'Page [Page] of [Pages]'?
 
jwashing2
Regarding the subreports, if a subreport may not have data you have to test for data using the HasData property.

Assuming that you want a total from each subreport, and you have a control in the subreport footer that gives that total, put a text box in the main report that has the following expression,...
Code:
=IIf([YourSubreportName].[Report].[HasData]=-1,[YourSubreportName].[Report]![YourSubreportTotalBoxName],0)

Do a separate text box for the second subreport.

Regarding the pages, put this expression in a text box in the report footer.
="Page " & [Page] & " of " & [Pages]

Tom
 
THWatson,

Thanks for responding. I tried the code you offered in each section of my Main report, but the summary of violations report still comes up as a blank page when there is no data.
 
You can't show a subreport that has no data. You can place controls in your main report that might be set to visible if the subreport doesn't contain any records.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Since I can't show a subreport that has no data, is there a way to:
1) Open the Main report
2) Check if either subreport has no data
3) set the subreport's recordsource to display a static "No Data Found" subreport
4) Number each page consecutively (whether data or no data found)

 
You can use a text box with a control source like:
=IIf(mysbrpt.Report.HasData = False, "No Data Found","")

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top