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!

Formula Calculation Problem

Status
Not open for further replies.

Deleco

Programmer
Feb 25, 2002
109
GB
Hi

I have a problem with a formula in my crosstab report in crystal 9.

When i run the report for the first time it gives me one value, if i then edit the formula in a way that should not change the result (i.e. change a string variable that i do not use) and then close and save the formula the report is refreshed and then the correct answer is given. (STRANGE!!!)

Has anyone experienced anything like this before? is there an easy solution to this problem?

Any help would be appreciated.
Regards
Deleco

Deleco
 
Perhaps you have the File->Save data with report turned on and it's not being refreshed the first time?

Obviously modifying an unused variable "shouldn't" make any data change, but there are glitches.

Also make sure that you apply the latest service pack:


-k
 
I have made sure that the data is not being saved with the report (File-Save data) and i am now downloading the latest service pack (sp2 for crystal 9).

I have came across some formula commands while reading records and while printing records could these have anything to do with it?

Deleco

Deleco
 
No, probably not.

Crystal is a 3 pass system, which allows for calculating totals, etc., but it doesn't save anything from execution to execution.

Are there subreports involved?

Perhaps you have saved data in one of those, hard to say.

-k
 
No there are no subreports. I will wait to see what happens after i have installed the service pack and then i will post the results.

Cheers

Deleco
 
post the formula!!!!

Just for the heck of it add "WhilePrintingRecords"
If it is not used for summary operations r grouping it will do no harm and perhaps some good....but in any case Show us the problem!

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Here's the code... It doesn't seem that there is anything obvious wrong but a new face looking at it might spot something..

numberVar lWorkDays;
StringVar sWorkControlNo;
StringVar sTemp;

If sWorkControlNo = {TBLVISITHEADER.DEFINING_CONTROL_NO} then
lWorkDays:=0
else
lWorkDays:=cdbl({TBLVISITHEADER.SNGTOTALWORKDAYS});

sTemp := "fffff";
sWorkControlNo := {TBLVISITHEADER.DEFINING_CONTROL_NO};

lWorkDays


any ideas????


Deleco
 
Try this :

WhilePrintingRecords;
numberVar lWorkDays;
If {TBLVISITHEADER.DEFINING_CONTROL_NO} = Previous({TBLVISITHEADER.DEFINING_CONTROL_NO}) then
lWorkDays:=0
else
lWorkDays:=cdbl({TBLVISITHEADER.SNGTOTALWORKDAYS});
lWorkDays;

Reebo
UK

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."
- Albert Einstein (1879-1955)
 
Almost Brilliant!!!!! Give that man a STAR.

The only problem is it misses out the first record, any ideas here.

I've tried checking the Previous function return value for an empty string but this did not work.


Deleco
 
Try:

WhilePrintingRecords;
numberVar lWorkDays;
If {TBLVISITHEADER.DEFINING_CONTROL_NO} = Previous({TBLVISITHEADER.DEFINING_CONTROL_NO}) and not(onfirstrecord) then
lWorkDays:=0
else
lWorkDays:=cdbl({TBLVISITHEADER.SNGTOTALWORKDAYS});
lWorkDays;

-k
 
Thanks for the advice but that does not appear to work any other ideas????

Here is the current formula code

WhilePrintingRecords;


If {TBLVISITHEADER.DEFINING_CONTROL_NO} = Previous({TBLVISITHEADER.DEFINING_CONTROL_NO}) then
0
else
cdbl({TBLVISITHEADER.SNGTOTALWORKDAYS});





Deleco
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top