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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

no data and divide by zero problems - CRXI 2

Status
Not open for further replies.

mgason

Technical User
Feb 6, 2003
158
AU
Hi,
I have some formulas in my report which involve division. One variable divided by another causes a divide by zero error when there is no data.
Sometimes a user will select a date range and parameters for the report which returns no matching records.
I then end up with estimated time zero/actual time zero and the report pops up the divide by zero error dialog and does not display.

How does one handle this sort of thing?
can I somehow have a report display "No Batches Mixed in Selected Time Frame" when there is no data, plus handle the divide by zero so it does not blow up?

thanks mark
 
Division should always allow for zero on the divisor:

if not(isnull(<blah>))
and
<blah> <> 0 then
x / <blah>
else
0

-k
 
Hi,
To eliminate the divide by zero:

Create a formula for those variables/fields that may be 0 under some conditions to handle that situation
If {datafield} = 0
then
1
else
{datafield}


Use the formula insted of the actual field in your report.

To show the message:

Insert a TEXT field in your report with that message and suppress it unless there are no records..



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Thanks,
I took care of all my divisions as you said and suppressed the text box as you mentioned. All fine.

of course I have another question!

I have a group By recipe
In the group details is a field Batch_ID
for each batch Id there is a Weight
I sum Weight and display it in the group header.
Sometimes a batch is not weighed and the value in Weight is I believe a Null (SQL database field is set to allow nulls)
I allow drill down in the group

I need to achieve 3 things
1.
In the drill down I would like to hilite any weight field for a batch that returns a null by making it a red background with no text.

2.
I would like to also hilite the sum weight in the group header with a silver background to indicate there were nulls.

3.
I would like to show somewhere in the Group header a count of the null fields.

Thanks for all your help
mark
 
mgason, please start a new thread for a new topic.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Syn,

Thanks, I was looking for something like that solution and I think I might just have been to tired to see it. But, anyways, thank you for a very elegant solution.



-- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top