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

What is wrong with this formual syntax

Status
Not open for further replies.

mgkSHA

Programmer
Jul 12, 2002
126
US
Hello:

With assistance from other programmers on this board I am trying to get a running total field to work on my report. Based on advice I have been given I am trying to convert a string to a interger and then back to the same format so I can do some calculations. On both formulas and when I try to run the Crystal report, I get the same error over and over: "THE ( IS MISSING". Why is this happening, what is wrong with the formulas I am using.

First one: in details section to convert format:

(tonumber(left({ado.correctedduration},2)*60)*60+
tonumber(mid({ado.correctedduration}4,2))*60+
tonumber(mid({ado.correctedduration}7,2))


Second one: in group footer to return format:

whileprintingrecords;
numberVar dur:={#RTotal1};
numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;

hrs:=Truncate(Truncate(dur/60)/60);
min:=Remainder(Truncate(dur/60),60);
sec:=Remainder(dur,60);

hhmmss:=totext(hr,"0") + ":" + totext(min, "00") + ":" + totext(sec, "00");

hhmmss


Both formulas return the same error, what is wrong with my syntax?
 
OK, I changed my initial formula to the following:

WhilePrintingRecords;
numberVar result;

result := tonumber(left({ado.correctedduration},2))* 3600
+ tonumber(mid({ado.correctedduration},4,2)) * 60
+ tonumber(right({ado.correctedduration},2));

result;

this seems to work.

But my second formula in the group footer to get the sum and re-format the data still is giving the error. Any suggestions?
 
You're trying to redeclare your variable "hrs" as "hr".
 
Naith:

I caught that error, hr should have been hrs, but now the second formula is giving me the error: "A number is expected here" on the line:

numberVar dur:={#RTotal1};

#RTotal1 is the running total field which I am trying to populate with the sum of all the ado.CorrectedDuration data in each group.

Any ideas? I seem to be getting closer and closer to finally solving this.
 
OK, in order to avoid the "number required error" I tried the following code and the syntax did not through an error. However, when I ran my report, I did not get the results I need, the sum of the correctedduration field for each group in the runningtotal field.

I put the intial formula (see above)in the details section where the records are, I put this formula in the group footer where the runningtotal field is. Any ideas? Maybe the location is wrong? Maybe the formula? Thanks

whileprintingrecords;
numberVar dur:=Val({#RTotal1});
numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;

hrs:=Truncate(Truncate(dur/60)/60);
min:=Remainder(Truncate(dur/60),60);
sec:=Remainder(dur,60);

hhmmss:=totext(hrs,"0") + ":" + totext(min, "00") + ":" + totext(sec, "00");

hhmmss
 
What is the objective of this exercise?

I'm aware that you're trying to change a non-time field into a time, but what isn't clear is why you simply don't change the finished total to a time rather than the incrementing running total.

Display an example of what the running total is doing, compared with where this formula will be displayed.

Naith
 
Naith:

OK, I think what the problem is, is that I haven't declared my running total as the sum of the fields. The point of these two formulas:


I have an Extension report, this report tells the user each phone number a specific Extension has dialed and how long each call was (the corrected duration field). I have two running total fields created 1) counts the number of times a phone number has been dialed 2) adds up the total amount of time (the total duration for each phone).


Here is the problem, the correctedduration field is a string, but it reads like this: 00:23:05. This represents 23 minutes and five seconds, but it is in string format. So, since I need to get a sum of these durations, I need to use a formula to first convert this into an integer and then convert it back to the 00:00:00 format.

The two formulas I have seem to work, the detail section converts these strings into integers, and the group footer formula shows this value 00.00.00. My problem is, my running total field isn't adding up the values found within the group. I seem to have the formatting working, but not the values.

How can I code my runningtotal field to add up all the values within the group, when it is a string? I seem to be able to convert the details section, but the runningtotal field is not adding those up.

Please advice, I can use all the help I can get right now :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top