Re: Close a Report When Sub-Reports are Empty
- From: Stefan Hoffmann <stefan.hoffmann@xxxxxxxxxx>
- Date: Wed, 29 Aug 2007 17:01:10 +0200
hi Keith,
Keith Wilby wrote:
I have an unbound report which contains two subreports. I've used the method suggested by Al to count the records in the subs but I want the main report to close if both subs are empty. I've successfully trapped error 440 in various events but each time I useUse a bound report with a SQL statment like that
DoCmd.Close acReport, Me.Name
I get an error saying that the action isn't possible whilst the report is formatting. Does anyone have a solution?
SELECT * FROM [yourTable] WHERE 0 = 1
As this will never return a record, the event on no data is called. In this event, you can count the recordsets of the subreport. If they are 0 then you set Cancel = True and the report will not be printed:
Private Sub Report_NoData(Cancel As Integer)
Dim RecCount As Long
RecCount = DCount(<subreport1>) + DCount(<subreport2>)
Cancel = (RecCount = 0)
End Sub
mfG
--> stefan <--
.
- Follow-Ups:
- Re: Close a Report When Sub-Reports are Empty
- From: Keith Wilby
- Re: Close a Report When Sub-Reports are Empty
- References:
- Close a Report When Sub-Reports are Empty
- From: Keith Wilby
- Close a Report When Sub-Reports are Empty
- Prev by Date: Re: Close a Report When Sub-Reports are Empty
- Next by Date: Re: Close a Report When Sub-Reports are Empty
- Previous by thread: Re: Close a Report When Sub-Reports are Empty
- Next by thread: Re: Close a Report When Sub-Reports are Empty
- Index(es):
Relevant Pages
|
|