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!

Division by zero but no 0 anywhere 2

Status
Not open for further replies.
Sep 12, 2005
448
US
hi All
cr 9.0
ms sql
i have this report that contains 2 subreports
1. i have these amount
sub report 1YTD sub report 2 Rep_Count
1062875/5294
1019197/4397
556346/4080
1123620/3837
409887/2801
3211420/1916
523793/2512
410306/2956
264899/2051
395437/3988
70871/1790
68954/2511
i'm dividing YTD by Rep_Count as you can see there no sero anywhere to be found
im using a shared variable to pass it to the main report.
in one of my sub report i'm using a count of rep
-------------------------------------------
here are my formula for the sub report YTD
@Total
WhilePrintingrecords;
shared NumberVar Sub2Total:={@Sum_YTD}

the formula for the @Sum_YTD is this
sum({@YTD_SLS},{TERR1_LIST.DESCRIPTION})

the YTD_SLS formula is this
if
{TRANSACTION_HISTORY.POSTING_DATE} in Date(year({?sub2_End_Date}),1,1) to
Date(Year({?sub2_End_Date}),Month({?sub2_End_Date}),day({?sub2_End_Date}))
and
{TRANSACTION_HISTORY.TRADE_CLASS} = "S"
then
{TRANSACTION_HISTORY.GROSS_AMOUNT else
0
-------------------------------------
for the rep sub report i have these formula
@Count_Rep
if
{CONTACT.CSTM_Active_Status} = "Active"
then
{TERR1_LIST.DESCRIPTION}

formula for total rep
@Total_Rep
count({@Count_Rep})

formula Total
WhilePrintingRecords;
Shared NumberVar Sub1Total:={@Total_Rep}


in my main report i have this formuls shared variable

@Sub_Total
WhilePrintingrecords;
Shared NumberVar Sub1Total;
Shared NumberVar Sub2Total;
Sub2Total/Sub1Total

i have no 0 anywhare but still gives division by sero error






Durango122
if it moves and should not used Duck Tape
if does not move and should used WD-40
 
Computers don't make that sort of error. I'd suggest you use
Code:
WhilePrintingrecords;
Shared NumberVar Sub1Total;
Shared NumberVar Sub2Total;
if Sub1Total <> 0
Sub2Total/Sub1Total
Maybe also do a test version of your report in which you show intermediate steps and find out how the zero sneeks in.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Probably the second subreport, regardless, you should code accordingly, and addingtoMawawcs:

WhilePrintingrecords;
Shared NumberVar Sub1Total;
Shared NumberVar Sub2Total;
if Sub1Total <> 0
Sub2Total/Sub1Total
else
0

-k

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top