Rabu, 22 Oktober 2014

RE: [MS_AccessPros] No Data on Report

 

Typically a subreport displays related "child" records related to a field or fields in the main report. This is not always the case. I have created many reports where a subreport isn't linked via Link Master/Link Child. This works well for displaying summary information in a report or group header or footer.
 
I agree that an unbound main report with two subreports might be the best solution in this instance.
 
Duane Hookom MVP
MS Access
 

To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Thu, 23 Oct 2014 00:57:05 +0530
Subject: Re: [MS_AccessPros] No Data on Report



Sarah

The point of having a subreport on a main report is so that you can see data related to the main report in the subreport.
Since the two reports that you have are mutually exclusive:

1 - Remove the subreport from the main report.
2 - Save the main report as rep1.
3 - Save the sub report as rep2.
4 - Create a new blank report.
5 - Add your rep1 at the top.

(As advised by John)
6- Make the height of the report as short as possible.
7 - Select the report and make the can grow property to true.

8 - Add the rep2 below this.
9 - Follow steps 6,7 for this second report.

Save this and run.
The report with no data will not be seen and the report with data will be seen. No other code might be required.

regards
Rajiv



On Thu, Oct 23, 2014 at 12:41 AM, 'Graham Mandeno' graham@mandeno.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
 

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

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
    Else
        Me.subrpt1.Visible =true

    End 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: Duane Hookom <duanehookom@hotmail.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (11)

.

__,_._,___

Tidak ada komentar:

Posting Komentar