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

Running totals not adding up correctly

Status
Not open for further replies.

MadCatmk2

Programmer
Oct 3, 2003
145
GB
Hi

Crystal 9.0 with access database

I have a report which takes referrals for patients. From these referrals i want to be able to count the records that are referred on to other departments and those that haven't.

I have a two formulas set up

@Inc which checks the record to see if it has been referred on and assigns the value 1 if so and 0 if not.

@IncTotal which sums up the @inc formula.

The problem i have is that if the last record shown in the details is one which recieves a 1 from the @Inc formula then the final @IncTotal sums up to one more than it should.
The same happens when i count those records that aren't referred on, if the last record isn't referred on then the count is 1 greater than it should be.

{@inc}

global numbervar counter;
whileprintingrecords;
if not isnull({1_ALL_REFERRALS.OTHER_AGENCIES_REFERRAL})
then
counter:=counter+1;

{@IncTotal}

global numbervar counter;
evaluateafter({@inc});
counter;

If anyone has any ideas what may be causing this i'd appreciate the help.

Thanks in advance
 
Firstly, change your formulas to:

{@inc}

whileprintingrecords;
global numbervar counter;
if Not(isnull({1_ALL_REFERRALS.OTHER_AGENCIES_REFERRAL}))
then
counter := counter+1;
else
counter;


{@IncTotal}

WhilePrintingRecords;
global numbervar counter;

Ensure {@inc} is placed in the detail and {@IncTotal} is placed in the footer. This should work.

Another way of doing this would be as follows :

{@inc}
if Not(isnull({1_ALL_REFERRALS.OTHER_AGENCIES_REFERRAL})) then 1 else 0;

Place this in the detail then right click > insert > summary > sum.


Reebo
UK
 
Thank you very much, your first suggestion done the trick i have no rogue numbers being summed now :eek:D

Your help is much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top