Hi Sarah
The most common purpose of the NoData event procedure is to set the Cancel argument and prevent the report from opening. However, it can perform other functions instead.
I suggest you declare a module-level Boolean variable, NoDataFlag, and use the NoData event procedure to set this to True, but do not set Cancel.
Then, in the Format event procedure of your Detail section, you can check its value and Cancel the section if required:
If NoDataFlag then Cancel = True
Do the same in any other sections you wish to hide.
Best wishes,
Graham
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Thursday, 23 October 2014 03:49
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] No Data on Report
I dont know if I explained correctly:
In this case the main report has no data, the subreport does have data. So I would like like to print the subreport without the main report.
Sarah
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
Sarah-
Rajiv makes some excellent suggestions. I'm wondering why the data on the report and subreport aren't related.
Another trick with subreport controls: Make sure they have Can Grow set to True and design them on the report so that they have no border and are just 0.1" high. If there are no rows, the subreport won't expand beyond that. If there are rows, it'll expand to display them all.
John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
(Paris, France)
On Oct 22, 2014, at 8:03 AM, Rajiv torajiv@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
you can also try
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.subrpt1.Report.HasData = True Then
Me.subrpt1.Visible = False
ElseMe.subrpt1.Visible =trueEnd If
End Sub
On Wed, Oct 22, 2014 at 11:25 AM, Rajiv <torajiv@...> wrote:
Sarah
If the report and subreport are not linked to each other why not have a report with two subreports instead of a report and subreport?
In the onformat event on the parent report you can use a dcount function to determine the number of records of each report and then make the one with no records invisible.
example
if nz(dcount("[id]","qryOne"),0)=0 then
report1.visible=false
else
report1.visible=true
endif
similarly for second report.
Rajiv
On Wed, Oct 22, 2014 at 5:04 AM, sarahk@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
I have a report with a subreport. The data for the report and the subreport are coming from 2 different queries. If the report has no data, I would still like to print the subreport. But when I test for no data and cancel the report , it does not print the subreport. How do I do this?.
If I print the report with no data, it looks ugly, because there are '#error's printing on the report.
As always, thanks in advance for your help
Sarah
Posted by: "Graham Mandeno" <graham@mandeno.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (9) |
Tidak ada komentar:
Posting Komentar