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

Report with No Data 2

Status
Not open for further replies.

mkov

Programmer
Sep 10, 2003
203
US
I have an unbound report with 2 subreports that is opening with no data even though I have the following code in the OnNoData event of the report and each of the sub reports.

MsgBox ("There is no data for the report."), , "Message Alert"
Cancel = True

This code works great on a bound report, but I am not sure what to do with a unbound report with sub reports.

Thanks in advance for your help.

 
That gets tricky because each sub report acts like an individual report. You would need a way to check to see if there is any data for eaither report. If there is none for either of them, then your message box would be printed. You would probably need to write some code in the main report that would check the sub reports, or have some code in the sub report that would pass back to main report.

If you check out the vba forum, someone there could probably help.
 
You could use code in the main report like:
If Me.srptMySub1.Report.HasData = False AND _
Me.srptMySub2.Report.HasData = False Then
MsgBox "There ain't no data in either sub"
End If

Duane
MS Access MVP
 
dhookom,

I gave it a try and keep getting the following error:

2451 - The report name "Subreport1" you entered is misspelled or refers to a report that isn't open or does not exist.

I have double checked the spelling, and it is correct. I am sure the problem is that it has not opened the report yet. Where would put this code on the main report - OnOpen?

Thanks.
 
You must use the subreport control name rather than the subreport name. These could be different.

Duane
MS Access MVP
 
The control name is the same.
 
Try place the code in the On Format event of the section containing the subreports.

Duane
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top