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!

the summary / running total field could not be created

Status
Not open for further replies.

andoryuu

MIS
Feb 16, 2005
11
US
Okie Dokie,

I have the following formula called @TimeCalc:

//Variable to hold in and out subtraction
Numbervar ECRTimeCalc;

//Take Log Out time and Subtract the Log In Time
if previous({sc42uact.option}) = "Application Entered" AND {sc42uact.option} = "Application Exited" then timevalue({sc42uact.date_time} - previous({sc42uact.date_time}))


I want to sum that information, so I convert the fields to seconds for adding, which works fine with my @ConvertTimeToSeconds formula:

local numbervar hours;
local numbervar minutes;
local numbervar seconds;
local numbervar totaltime;

// Convert the hours to seconds by multiplying by
// 3600
hours := hour({@TimeCalc}) * 3600;

// Convert the minutes to seconds by multiplying by
// 60
minutes := minute({@TimeCalc}) * 60;
seconds := second({@TimeCalc});

//add up all the seconds
hours + minutes + seconds;


However, I get the "the summary / running total field could not be created" error when I try to run the following simple formula called @TimeSum:

if {@ConvertTimetoSeconds} <> 0 then
Sum ({@ConvertTimetoSeconds},{sc42uact.user})



Anyone know where I'm going wrong?
 
Your formula is a printing pass formula, so it's not available to aggregate functions.

Use a variable to sum them at the detail level:

whileprintingrecords;
numbervar MySum;
local numbervar hours;
local numbervar minutes;
local numbervar seconds;
local numbervar totaltime;

// Convert the hours to seconds by multiplying by
// 3600
hours := hour({@TimeCalc}) * 3600;

// Convert the minutes to seconds by multiplying by
// 60
minutes := minute({@TimeCalc}) * 60;
seconds := second({@TimeCalc});

//add up all the seconds into an ongoing sum
MySum:=MySum+hours + minutes + seconds;

Reset this at the {sc42uact.user} group header level using:
whileprintingrecords;
numbervar MySum:=0;

Then display at the group header level:
whileprintingrecords;
numbervar MySum

-k
 
Thanks for your super-fast reply!

Forgive me. . . I'm PAINFULLY new at this.

I altered my ConvertTimeToSeconds formula with the

WhilePrintingRecords;
numbervar MySum;
MySum = MySum + {etc.};

lines, but perhaps I'm putting the other lines in the wrong place . . .? Where do the following lines go?

Reset this at the {sc42uact.user} group header level using:
whileprintingrecords;
numbervar MySum:=0;

Then display at the group header level:
whileprintingrecords;
numbervar MySum

I have the Time to Seconds conversion as a field on my report and where it at one time showed, let's say 10800 seconds for 3:00 hours, it now says TRUE (and where the time is 0 (or null) it says FALSE. Any ideas?

-Andrew
 
I posted the right formula for the details section, it looks like you changed it to just the MySUm part.

The other code goes in separate formulas in the sections desginated.

Your formula showed that you were attempting to sum at the
{sc42uact.user} group level, so I coded accordingly.

-k
 
No, it still shows up as False and True for the ConvertTimeToSeconds part -- I had placed the formulas in the correct place. Could this be because the TimeCalc has to calculate using the previous field?

-=Andrew=-
Database Support Specialist
"Shinakya ikenai koto ga takusan aru shi . . ." -Utada Hikaru
 
Nope.

The following formula should never display as true/false unless it's in the wrong place:

whileprintingrecords;
numbervar MySum

You need to create formulas, not paste it into some section's code or some such.

Go into the Field Explorer and Right click Formula Fields and select New.

There will be 3 formulas in total.

-k
 
SV mistakenly said to place the display formula in the group header--it belongs in the group footer:

whileprintingrecords;
numbervar MySum;

The last line of your converttimetoseconds formula should read:

MySum := MySum + hours + minutes + seconds;

-LB
 
These were created as formulas and placed in the correct place.

As I said in my original reply, it wasn't the MySum that is printing as True/False (it's showing up as Zero) it's the ConvertTimeToSeconds Function that used to show up correctly, but the code you added makes it non-functional.

-=Andrew=-
Database Support Specialist
"Shinakya ikenai koto ga takusan aru shi . . ." -Utada Hikaru
 
I know that he was incorrect about his placement . . . i just put it in the correct place anyway (the functionality is to reset the container at each group . . . set it to zero for the header, accumulate in the detail, print in the footer).

But you spotted the problem. I was performing a test instead of an assignment ("=" instead of ":=") That made it show up as True/False instead of assigning the amount of time for that detail line. Thanks for your expert help everybody!

-=Andrew=-
Database Support Specialist
"Shinakya ikenai koto ga takusan aru shi . . ." -Utada Hikaru
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top