Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Crystal giving error when running report with complicated formula

Posted on 2008-06-16
9
Medium Priority
?
395 Views
Last Modified: 2013-11-16
I am trying to run a Crystal report that totals the number of records that don't have data in a specific field/table.  Because I'm looking for data lines that may not exist, I created a formula as a running total.  Earlier in the report I set the various NullValue variables to "Y".  If, after the details section, they are still "Y", then I know it didn't find a line with the data, so I increment the number of records by one.

The problem is I'm getting an error when I run the report, and, unlike other errors I've seen, this one isn't telling me what the error is, just that there's an error (see screenshot).  I tried creating a new formula to only call the below formula if the {table_add_detail.field_value} isn't null, but it seems to be calling the formula anyway.

Any ideas on what the error is, and how to fix it?
whileprintingrecords;
stringvar RDNullValue;
stringvar NullValueH;
stringvar NullValueP;
stringvar MDNullValueH;
stringvar MDNullValueP;
numbervar HRunning;
numbervar HNumRecs;
numbervar PRunning;
numbervar PNumRecs;
 
if isdate({table_add_detail.field_value}) then
(
if {table_add_detail.field_name}="REC DISPOS" and
cdate({table_add_detail.field_value})<={?DateRange} then
RDNullValue:="N"
);
if isdate({table_add_detail.field_value}) then
(
if {table_add_detail.field_name}="DT REQ SEC" and
cdate({table_add_detail.field_value})<={?DateRange} then
(if {table_add_detail_lob.field_value}="Commercial" then
NullValueH:="N" else
if {table_add_detail_lob.field_value}in["BT", "BC", "BP", "Blue Opt", "HCH", "P65", "FEP"] then
NullValueP:="N"
);
);
if {table_add_detail_lob.field_value}="Commercial" then
(HNumRecs:=HNumRecs+1;
HRunning:=HRunning+DateDiff("d", cdate({cme_detail.document_id}), {cme_detail.response_date}));
if {table_add_detail_lob.field_value}in["BT", "BC", "BP", "Blue Opt", "HCH", "P65", "FEP"] then
(PNumRecs:=PNumRecs+1;
PRunning:=PRunning+DateDiff("d", cdate({cme_detail.document_id}), {cme_detail.response_date}));
 
if isdate({table_add_detail.field_value}) then
(
if {table_add_detail.field_name}="DATE TO MD" and
cdate({table_add_detail.field_value})<={?DateRange} then
(if {table_add_detail_lob.field_value}="Commercial" then
MDNullValueH:="N" else
if {table_add_detail_lob.field_value}in["BT", "BC", "BP", "Blue Opt", "HCH", "P65", "FEP"] then
MDNullValueP:="N"
);
);

Open in new window

Crystal1.jpg
0
Comment
Question by:VistarTechnologies
[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
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 21794454
How are you calling the formula?

Is the error when you run the report?

mlmcc
0
 

Author Comment

by:VistarTechnologies
ID: 21794479
I am calling the formula with the below formula, located in the Details section:

whileprintingrecords;
if isnull({table_add_detail.field_value}) then
"A" else {@RunningTotal};

The error is when I run the report.  It spends some time, loads records, but gives the error before it prints anything.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 21796432
A formula must return a single data type.  Try

whileprintingrecords;
if isnull({table_add_detail.field_value}) then
0 else {@RunningTotal};

mlmcc
0
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

Author Comment

by:VistarTechnologies
ID: 21797354
When I updated the formula as suggested, it gave me an error "A number is required here" and highlighted {@RunningTotal}, so I couldn't change it.  I then tried changing the RunningTotal formula to end with 0 so it would always return a number, which then allowed me to update the formula as suggested... however, running the report produced the same error.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 21797711
Sorry, your formula name confused me.  The character is correct.

Does the report work from the Crystal designer?

mlmcc
0
 

Author Comment

by:VistarTechnologies
ID: 21797779
I'm not exactly sure what the Crystal designer is... is that somewhere in Crystal Reports?
0
 
LVL 35

Accepted Solution

by:
James0628 earned 2000 total points
ID: 21798578
Are you sure that {@RunningTotal} isn't being used anywhere else in the report?  If you want to make sure, when you look at the list of formulas in the field explorer in CR, does your version put check marks by the formulas that are being used?  If so, try removing the reference to {@RunningTotal} from the formula that calls it and see if there is still a check mark beside {@RunningTotal}.  If there is, it's being used somewhere else.

 If all else fails, you could add IsNull tests before the IsDate at the start of each if statement in {@RunningTotal}.  Something like:

if not IsNull ({table_add_detail.field_value}) and isdate({table_add_detail.field_value}) then


 I'd also suggest adding an IsNull test for {table_add_detail_lob.field_value}:

if not IsNull ({table_add_detail_lob.field_value}) and
 {table_add_detail_lob.field_value}="Commercial" then


 Or ...
 CR 10 has an option to replace incoming nulls with default values (an empty string for string fields and 0 for numeric fields).  If your version of CR has that option, and if you don't actually need the null values for some reason, you could try that option to just eliminate the nulls from the equation.  In CR 10, the option is under File > Report Options - "Convert Database NULL Values to Default".

 James
0
 

Author Closing Comment

by:VistarTechnologies
ID: 31467630
Replacing incoming nulls with default value solved issue.
0
 
LVL 35

Expert Comment

by:James0628
ID: 21807651
Glad I could help.

 James
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
How to increase the row limit in Jasper Server.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question