views:

937

answers:

2

The following line in my crystal reports formula is giving the error:

NumberVar sales0405 := Sum ({sp_YES_AccountSnapshot;1.ST0405_Ext}, {sp_YES_AccountSnapshot;1.Cust}) + Sum ({sp_YES_AccountSnapshot;1.DR0405_Ext}, {sp_YES_AccountSnapshot;1.Cust});

The error:

"The ) is missing"

The report was created using Crystal reports 11.

The report runs fine when I run it from within Crystal Reports.

However, when I run the report from an ASP.NET web app utilizing the Crystal Reports Basic for Visual Studio .NET 2008 (Updated May 2008) (provided at http://resources.businessobjects.com/support/additional_downloads/runtime.asp#09), this is when I get the error.

I'm guessing there is some change in summations with the newer versions of Crystal Reports, but I've been unable to find any documentation on this specific issue.

I have verified that there are no null values coming in on my test case that produces an error.

The line that is producing the error is the first line of the formula.

Thanks in advance for your time

Edit: Here's the entire formula

*NumberVar sales0405 := Sum ({sp_YES_AccountSnapshot;1.ST0405_Ext}, {sp_YES_AccountSnapshot;1.Cust}) + Sum ({sp_YES_AccountSnapshot;1.DR0405_Ext}, {sp_YES_AccountSnapshot;1.Cust}); NumberVar sales0304 := Sum ({sp_YES_AccountSnapshot;1.ST0304_Ext}, {sp_YES_AccountSnapshot;1.Cust}) + Sum ({sp_YES_AccountSnapshot;1.DR0304_Ext}, {sp_YES_AccountSnapshot;1.Cust}); if sales0304 = 0 then ToText ("Increase in Sales: N/A") else if(sales0405 < sales0304) then ToText ("") else "Increase in Sales: " + Replace (ToText (Int(RoundUp ((((sales0405 - sales0304) / sales0304) * 100)))), ".00", "") + "%"*

As it turns out, it's that last line that's causing the problem. Any Idea why? I fixed it by removing the Replace, Int, and Roundup functions from it (eliminating a few parentheses in the process.

Note: sorry about the poor formatting with that code, I couldn't get the code tag to place nice with the multi-line copy paste from crystal.

+2  A: 

I would:

  1. Define a group in the details section for {sp_YES_AccountSnapshot;1.Cust}
  2. Update the function to resemble:

    NumberVar sales0405 := SUM({sp_YES_AccountSnapshot;1.ST0405_Ext}) + SUM({sp_YES_AccountSnapshot;1.DR0405_Ext});

  3. Place the function in the footer of the group

  4. Suppress the group header

You might have to use the Overlay Section Beneath option (see the Section Expert) to get the layout you desire.

OMG Ponies
hamlin11
You are correct.
OMG Ponies
Any thoughts on my edit above rexem? Thanks.
hamlin11
+2  A: 

Multiple return statements are never a good idea:

NumberVar sales0405 := Sum ({sp_YES_AccountSnapshot;1.ST0405_Ext}, {sp_YES_AccountSnapshot;1.Cust}) + 
                       Sum ({sp_YES_AccountSnapshot;1.DR0405_Ext}, {sp_YES_AccountSnapshot;1.Cust}); 

NumberVar sales0304 := Sum ({sp_YES_AccountSnapshot;1.ST0304_Ext}, {sp_YES_AccountSnapshot;1.Cust}) + 
                       Sum ({sp_YES_AccountSnapshot;1.DR0304_Ext}, {sp_YES_AccountSnapshot;1.Cust}); 

Stringvar output;

IF sales0304 = 0 THEN 
  output := ToText ("Increase in Sales: N/A") 
ELSE IF(sales0405 < sales0304) THEN 
  output := ToText ("") 
ELSE 
  output := "Increase in Sales: " + Replace (ToText (Int(RoundUp ((((sales0405 - sales0304) / sales0304) * 100)))), ".00", "") + "%";

output;

The last line, declaring the "output" variable is required so that Crystal knows what to print. This also ensures the data type is always the same.

OMG Ponies