From: RMP on
The query parameters correctly return no records. The report that is run
based on this query returns #Error in the report controls.
What is syntax to use so that when the query correctly returns no records a
Zero is displayed in the report instead of #Error.
Thank you for your help on this.

From: Duane Hookom on
You can use a control source like:

=IIf([HasData], Sum(Qty),Null)

--
Duane Hookom
MS Access MVP

"RMP" <u25421(a)uwe> wrote in message news:64ea9040d756a(a)uwe...
> The query parameters correctly return no records. The report that is run
> based on this query returns #Error in the report controls.
> What is syntax to use so that when the query correctly returns no records
> a
> Zero is displayed in the report instead of #Error.
> Thank you for your help on this.
>


From: fredg on
On Thu, 17 Aug 2006 18:56:16 GMT, RMP wrote:

> The query parameters correctly return no records. The report that is run
> based on this query returns #Error in the report controls.
> What is syntax to use so that when the query correctly returns no records a
> Zero is displayed in the report instead of #Error.
> Thank you for your help on this.

If the report has no records, the usual method is to just cancel
running the report.

Code the Report's OnNoData event:
MsgBox "There is no data to report on."
Cancel = True

If you have opened this report from a code event, this will raise
Error # 2501, so you need to trap that error in the event that opens
the report:

On Error GoTo Err_Handler
DoCmd.OpenReport "ReportName", acViewPreview
Exit_This_Sub:
Exit Sub
Err_Handler:
If Err = 2501 then
Else
MsgBox "Error #: " & err.Number & " " & err.Description
End If
Resume Exit_This_Sub
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
From: fredg on
On Thu, 17 Aug 2006 18:56:16 GMT, RMP wrote:

> The query parameters correctly return no records. The report that is run
> based on this query returns #Error in the report controls.
> What is syntax to use so that when the query correctly returns no records a
> Zero is displayed in the report instead of #Error.
> Thank you for your help on this.

If the report has no records, the usual method is to just cancel
running the report.

Code the Report's OnNoData event:
MsgBox "There is no data to report on."
Cancel = True

If you have opened this report from a code event, this will raise
Error # 2501, so you need to trap that error in the event that opens
the report:

On Error GoTo Err_Handler
DoCmd.OpenReport "ReportName", acViewPreview
Exit_This_Sub:
Exit Sub
Err_Handler:
If Err = 2501 then
Else
MsgBox "Error #: " & err.Number & " " & err.Description
End If
Resume Exit_This_Sub
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
From: RMP via AccessMonster.com on
Duane,

Thank for the tip that let to the solution.

I had to fields in my query {Amt} and [DetailAmt] which for the time period
specified there were correctly no records in the query and the report
generated #Error in the controls.

Using your suggestion, I modified my report controls as follows:

Iif([HasData], [Amt],0) and Iif([HasData],Sum([DetailAmt]).0)

Appeciate your help on this.

BTW, I looked on Microsoft's Access website for a solution and wasn't able to
find it. Can you recommend a good reference book?

Regards,

Richard


Duane Hookom wrote:
>You can use a control source like:
>
>=IIf([HasData], Sum(Qty),Null)
>
>> The query parameters correctly return no records. The report that is run
>> based on this query returns #Error in the report controls.
>> What is syntax to use so that when the query correctly returns no records
>> a
>> Zero is displayed in the report instead of #Error.
>> Thank you for your help on this.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-reports/200608/1