PC Review


Reply
Thread Tools Rate Thread

avoiding #ERROR in an empty report

 
 
Sharon
Guest
Posts: n/a
 
      8th Oct 2004
Hi,

I have fields that do "Sum" of other fields in the report.

When the report is empty, I get ERROR in the fields with
the sum calculation.
I tried to add this condition:
IIf([payment]="",0,sum([pament]) and it didn't change the
ERROR value of the field.

Any idea?

Thanks in advance,
Sharon
 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      8th Oct 2004
The report has a NoData event that fires if the report has no data. Just
cancel this event so the report does not show.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Sharon" <(E-Mail Removed)> wrote in message
news:24df01c4ad53$417d5480$(E-Mail Removed)...
>
> I have fields that do "Sum" of other fields in the report.
>
> When the report is empty, I get ERROR in the fields with
> the sum calculation.
> I tried to add this condition:
> IIf([payment]="",0,sum([pament]) and it didn't change the
> ERROR value of the field.
>
> Any idea?
>
> Thanks in advance,
> Sharon



 
Reply With Quote
 
AlCamp
Guest
Posts: n/a
 
      8th Oct 2004
Sharon,
I think you need to check out Help on "OnNoData" (Cancel the printing of
a report when it doesn't contain any records).
You're calcs will error because there's no data to report... no nulls, no
zeros, no values.
Using the Report's NoData event...

Private Sub Report_NoData(Cancel As Integer)
MsgBox "The report has no data." _
& "@Printing the report is canceled. " _
& "@Check the source of data for the report to make sure you " _
& "entered the correct criteria (for example, a valid range " _
& "of dates).", vbOKOnly + vbInformation
Cancel = True
End Sub

hth
Al Camp

"Sharon" <(E-Mail Removed)> wrote in message
news:24df01c4ad53$417d5480$(E-Mail Removed)...
> Hi,
>
> I have fields that do "Sum" of other fields in the report.
>
> When the report is empty, I get ERROR in the fields with
> the sum calculation.
> I tried to add this condition:
> IIf([payment]="",0,sum([pament]) and it didn't change the
> ERROR value of the field.
>
> Any idea?
>
> Thanks in advance,
> Sharon



 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      8th Oct 2004
Hi Al

You might want to update that code.
Since A2000, the "@" character does not work like that.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"AlCamp" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Sharon,
> I think you need to check out Help on "OnNoData" (Cancel the printing of
> a report when it doesn't contain any records).
> You're calcs will error because there's no data to report... no nulls,
> no
> zeros, no values.
> Using the Report's NoData event...
>
> Private Sub Report_NoData(Cancel As Integer)
> MsgBox "The report has no data." _
> & "@Printing the report is canceled. " _
> & "@Check the source of data for the report to make sure you " _
> & "entered the correct criteria (for example, a valid range " _
> & "of dates).", vbOKOnly + vbInformation
> Cancel = True
> End Sub
>
> hth
> Al Camp
>
> "Sharon" <(E-Mail Removed)> wrote in message
> news:24df01c4ad53$417d5480$(E-Mail Removed)...
>> Hi,
>>
>> I have fields that do "Sum" of other fields in the report.
>>
>> When the report is empty, I get ERROR in the fields with
>> the sum calculation.
>> I tried to add this condition:
>> IIf([payment]="",0,sum([pament]) and it didn't change the
>> ERROR value of the field.
>>
>> Any idea?
>>
>> Thanks in advance,
>> Sharon



 
Reply With Quote
 
AlCamp
Guest
Posts: n/a
 
      8th Oct 2004
OK. I didn't even see those characters. I just cut and pasted from my
Help to make my response clearer.
Thanks,
Al Camp

"Allen Browne" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Al
>
> You might want to update that code.
> Since A2000, the "@" character does not work like that.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "AlCamp" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Sharon,
> > I think you need to check out Help on "OnNoData" (Cancel the printing

of
> > a report when it doesn't contain any records).
> > You're calcs will error because there's no data to report... no nulls,
> > no
> > zeros, no values.
> > Using the Report's NoData event...
> >
> > Private Sub Report_NoData(Cancel As Integer)
> > MsgBox "The report has no data." _
> > & "@Printing the report is canceled. " _
> > & "@Check the source of data for the report to make sure you " _
> > & "entered the correct criteria (for example, a valid range " _
> > & "of dates).", vbOKOnly + vbInformation
> > Cancel = True
> > End Sub
> >
> > hth
> > Al Camp
> >
> > "Sharon" <(E-Mail Removed)> wrote in message
> > news:24df01c4ad53$417d5480$(E-Mail Removed)...
> >> Hi,
> >>
> >> I have fields that do "Sum" of other fields in the report.
> >>
> >> When the report is empty, I get ERROR in the fields with
> >> the sum calculation.
> >> I tried to add this condition:
> >> IIf([payment]="",0,sum([pament]) and it didn't change the
> >> ERROR value of the field.
> >>
> >> Any idea?
> >>
> >> Thanks in advance,
> >> Sharon

>
>



 
Reply With Quote
 
Sharon
Guest
Posts: n/a
 
      9th Oct 2004
Thanks you very much for your help.

I did like you suggested, and indeed the message appears
when I try to open an empty report. However, after this
message, the following message appears:
"Run-time error '2501'
The open report action was canceled"
and the option to Debug or Close.

How can I avoid this message?

Thanks a lot,
Sharon

>-----Original Message-----
>Sharon,
> I think you need to check out Help on "OnNoData"

(Cancel the printing of
>a report when it doesn't contain any records).
> You're calcs will error because there's no data to

report... no nulls, no
>zeros, no values.
> Using the Report's NoData event...
>
>Private Sub Report_NoData(Cancel As Integer)
> MsgBox "The report has no data." _
> & "@Printing the report is canceled. " _
> & "@Check the source of data for the report to make

sure you " _
> & "entered the correct criteria (for example, a valid

range " _
> & "of dates).", vbOKOnly + vbInformation
> Cancel = True
>End Sub
>
>hth
>Al Camp
>
>"Sharon" <(E-Mail Removed)> wrote in

message
>news:24df01c4ad53$417d5480$(E-Mail Removed)...
>> Hi,
>>
>> I have fields that do "Sum" of other fields in the

report.
>>
>> When the report is empty, I get ERROR in the fields

with
>> the sum calculation.
>> I tried to add this condition:
>> IIf([payment]="",0,sum([pament]) and it didn't change

the
>> ERROR value of the field.
>>
>> Any idea?
>>
>> Thanks in advance,
>> Sharon

>
>
>.
>

 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      9th Oct 2004
Error 2501 is just Access' way of notifying your code that the report did
not open. Use error handling in the procedure that calls OpenReport, and
just ignore the error:

This kind of thing:

Private Sub cmdPrint_Click()
On Error GoTo Err_Handler

DoCmd.OpenReport "MyReport", acViewPreview

Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number <> 2501 Then
MsgBox Err.Description, "cmdPrint_Click"
End If
Resume Exit_Handler
End Sub


--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Sharon" <(E-Mail Removed)> wrote in message
news:108501c4ae0c$347526f0$(E-Mail Removed)...
> Thanks you very much for your help.
>
> I did like you suggested, and indeed the message appears
> when I try to open an empty report. However, after this
> message, the following message appears:
> "Run-time error '2501'
> The open report action was canceled"
> and the option to Debug or Close.
>
> How can I avoid this message?
>
> Thanks a lot,
> Sharon
>
>>-----Original Message-----
>>Sharon,
>> I think you need to check out Help on "OnNoData"

> (Cancel the printing of
>>a report when it doesn't contain any records).
>> You're calcs will error because there's no data to

> report... no nulls, no
>>zeros, no values.
>> Using the Report's NoData event...
>>
>>Private Sub Report_NoData(Cancel As Integer)
>> MsgBox "The report has no data." _
>> & "@Printing the report is canceled. " _
>> & "@Check the source of data for the report to make

> sure you " _
>> & "entered the correct criteria (for example, a valid

> range " _
>> & "of dates).", vbOKOnly + vbInformation
>> Cancel = True
>>End Sub
>>
>>hth
>>Al Camp
>>
>>"Sharon" <(E-Mail Removed)> wrote in

> message
>>news:24df01c4ad53$417d5480$(E-Mail Removed)...
>>> Hi,
>>>
>>> I have fields that do "Sum" of other fields in the

> report.
>>>
>>> When the report is empty, I get ERROR in the fields

> with
>>> the sum calculation.
>>> I tried to add this condition:
>>> IIf([payment]="",0,sum([pament]) and it didn't change

> the
>>> ERROR value of the field.
>>>
>>> Any idea?



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Avoiding empty continuous form rsosabusiness@aol.com Microsoft Access Forms 6 7th Feb 2007 01:43 PM
avoiding 31/12/1899 with empty dates RB Smissaert Microsoft Access 9 15th May 2006 01:20 AM
Automatic avoiding empty cell Amag Microsoft Excel Charting 3 29th Jan 2006 05:37 AM
Avoiding empty cells in a DataList Nathan Sokalski Microsoft ADO .NET 1 22nd Sep 2005 09:27 AM
Avoiding "#Error" fields of calculation when the report is empty Liat Microsoft Access Reports 2 7th Aug 2004 08:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:07 PM.