Solved

# Crystal Variable Problem

Posted on 2011-03-01
340 Views
I have to update several shared variables based on the scrap code:

``````if {bsp_Quality.FaultCode}="99" then
M99:= M99 + {bsp_Quality.Qty};
TotalScrapM99:= TotalScrapM99 + {bsp_Quality.Qty};
TotalMatScrap:={bsp_Quality.Shot}*{bsp_Quality.Qty};
else if {bsp_Quality.FaultCode}="M01" then ...
``````

I get an error after this line M99:= M99 + {bsp_Quality.Qty};  stating the rest of the text is not part of the formula.
What am I missing?
0
Question by:RickCooper
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 25

Accepted Solution

reb73 earned 500 total points
ID: 35007959
If I'm not mistaken a multi-statement block has to be enclosed within brackets ()

if {bsp_Quality.FaultCode}="99" then
(    M99:= M99 + {bsp_Quality.Qty};
TotalScrapM99:= TotalScrapM99 + {bsp_Quality.Qty};
TotalMatScrap:={bsp_Quality.Shot}*{bsp_Quality.Qty};
)
else if {bsp_Quality.FaultCode}="M01" then ...
0

LVL 1

Author Comment

ID: 35008001
I get the ) is missing and TotalScrapM99: is highlighted
0

LVL 77

Expert Comment

ID: 35008090
The syntax for such code is a bit difficult.
Remove the ; on the line before the )

In your Else structure you need ...

else
(
firstline;
secondline;
thirdline
);
0

LVL 100

Expert Comment

ID: 35008148
What is the full code?

The variables don't appear to be declared.
All variables used in a formula must be declared in the formula.
Unlike some languages you must declare the variable in each formula not just in a formula at the start of the report.

mlmcc
0

LVL 1

Author Closing Comment

ID: 35008460
The Variable TotalMatScrap was not declared correctly.
0

LVL 100

Expert Comment

ID: 35009511
Since you had to change the declaration, why wasn't my comment selected as part of the answer.  The ( ) being required was part of the answer though not to the actual error.

mlmcc
0

LVL 1

Author Comment

ID: 35010185
mlmcc,

There was a typo in the variable. It had been declared, I checked the code before I read your post. Even without the typo the error was the same no ( )

Sorry.

0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
###### Suggested Courses
Course of the Month5 days, 20 hours left to enroll