Link to home
Start Free TrialLog in
Avatar of Derek Brown
Derek BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

HasData

I have a Report that has 3 sub reports. Each, all or none can have data. How do I stop the main and all reports printing if the subreports have no data
Avatar of PatHartman
PatHartman
Flag of United States of America image

In the Main Report's Load event, you will need to run two queries - one for each subform and count the related records.  If none are found, you can cancel the report.  Use the normal OnNoData method to cancel the main report.
try using the open event of the Main report to check if the sub report have data

private sub Report_Open(cancel as integer)

if Not me.subreportcontolname.report.hasdata  then
  msgbox "No data in subreport"
  cancel=true

end if

end sub
Avatar of Derek Brown

ASKER

Hi Ray

Can't get that to work. Unrecognised procedure

Pat
I do not have an load event for the report
which line is raising the error?
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There is always many different ways to solve access problems I will try them and respond
Sorry used these comments to solve problem. Cannot believe I forgot to close.

Thank you both