Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get rid of #Error on reports

Status
Not open for further replies.

devGarfield

Programmer
Mar 23, 2004
31
GB
Hi All,

I have a report that has a sum field called sumExamFeeCost = sum(detExamFeeCost) and a detail field called detExamFeeCost. The report runs off of a query, which can result in no records being returned. When no records are returned there are no records to sum or display. The details line show's blanks for this field, but the summed field is showing #Error.

I have tried nz(sum(sumExamFeeCost)) but I get the same error #Error.

What I would like to see in this case is either 0.00 or blanks as with the detail line.

The summed field is in a group footer

Many thanks
 
You could prevent the report from appearing if the recordset is empty. Just pop up a message box instead.

----------------------------
SnaveBelac - Adventurer
----------------------------
 
I tried iif(IsError(expression),0,expression) and it gave me the same answer.

This is what I have

=IIf(IsError(Sum(Exam Fee Cost]),0,Sum([Exam Fee Cost])) which gives me #Error

Also, the data for the form is based on a query, which in this case is returning an empty recordset. Probably need a way to check for empty recordsets before displaying any data

Any ideas?
 
Write an SQL statement (or copy the one created by the query) and run that prior to opening the report, in the event of an EOF, display a message box instead of opening the report.

----------------------------
SnaveBelac - Adventurer
----------------------------
 
The report is based on a automatically generated SQL query, how can I check for EOF within the report, I'm thinking of adding some code in the OPEN_REPORT event but don't know what to add for this check
 
And what about the NoData event procedure ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I am not an expert in access but I have been programming it for many years now - I had never come across the NoData event before - That should do the trick !!

----------------------------
SnaveBelac - Adventurer
----------------------------
 

Never heard of the NoData Event, but I tried it as suggested, but it didn't fire.

Any other suggestions?


 
You have a missing bracket in your expression:
=IIf(IsError([Sum(Exam Fee Cost]),0,Sum([Exam Fee Cost]))

I'd make the calculation text box (Sum([Exam Fee Cost]) invisible so that the Sum is triggered only once...

Place another textbox on the report to get the value from the invisible one:
=IIf(IsError(TotalTextBox), 0, TotalTextBox)



The NoData event should fire all right if you use the syntax:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "Oops, no data..."
Cancel = True
End Sub

Remember to trap the error 2501 (Action was canceled) in the calling code.



[pipe]
Daniel Vlas
Systems Consultant

 
How is you query being built? If you are creatng your recordset via code, you could check for zero records there.

Alternatively you could try checking for a different condition using your IIF statement...
Code:
=IIf(isNull([detExamFee]),0,Sum([Exam Fee Cost]))

I am not familiar with the NoData event so can't advise on that. I would recommend checking the help files for the details of how this works.

----------------------------
SnaveBelac - Adventurer
----------------------------
 
Well, I've managed to sort it out with all of your help.

My solution in the end was to create another textfield to store the result of the summation and hide it, then using the IIF(IsError.....) example from above displayed 0 in my report instead of #Error.

Thanks all for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top