[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Crystal Reports 2008 - Formula Error

Posted on 2012-09-06
11
Medium Priority
?
368 Views
Last Modified: 2012-09-07
I have is code:
StringVar A := IF ISNULL({TEMP_PWC_Report_SP_MAIN.minstrumenttype}) or {TEMP_PWC_Report_SP_MAIN.minstrumenttype} = '' then '' else {TEMP_PWC_Report_SP_MAIN.minstrumenttype};

I get an error that a number is required where the code is: = ' '

please help and thanks
0
Comment
Question by:Amour22015
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 800 total points
ID: 38373439
What data type is {TEMP_PWC_Report_SP_MAIN.minstrumenttype}?

Since you are assigning '' when it equals '' no need for the test

StringVar A := IF ISNULL({TEMP_PWC_Report_SP_MAIN.minstrumenttype})  then
    ''
else
    {TEMP_PWC_Report_SP_MAIN.minstrumenttype};

I don't see   := ' '  in the formula

mlmcc
0
 

Author Comment

by:Amour22015
ID: 38373494
mlmcc,

Now I am getting:

A String is required here ERROR

On:
{TEMP_PWC_Report_SP_MAIN.minstrumenttype};

I tryed:
({TEMP_PWC_Report_SP_MAIN.minstrumenttype});

Thanks
0
 
LVL 35

Expert Comment

by:James0628
ID: 38374044
It sounds like minstrumenttype is a number, in which case it will never be "" (an empty string).  Do you want to test for 0 instead?

 Your A variable is a string.  What do you want to put in that string if minstrumenttype is null?  If it's 0?  If it's some other number?

 James
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
LVL 101

Expert Comment

by:mlmcc
ID: 38374385
Are you trying to display this?

How about setting the report to convert NULL to a default value?

mlmcc
0
 
LVL 19

Assisted Solution

by:GJParker
GJParker earned 200 total points
ID: 38376458
This will work but as the others have said if your field is a number then this may not be what you really want

StringVar A := IF ISNULL({TEMP_PWC_Report_SP_MAIN.minstrumenttype})  then
    ''
else
    CStr{TEMP_PWC_Report_SP_MAIN.minstrumenttype});
0
 

Author Comment

by:Amour22015
ID: 38376586
Hi and thanks to everyone that helped.

I ended up doing this:
StringVar A := IF ISNULL({TEMP_PWC_Report_SP_MAIN.minstrumenttype}) then '' else '{TEMP_PWC_Report_SP_MAIN.minstrumenttype}';

this seems to work,

Since Mlmcc came up with the first section I am going to award with the highest points and GJParker came up with CStr which equals '      ' that I did should get some points.
Mlmcc = 400
GJParker = 100

just trying to be fair.

Thanks
0
 

Author Closing Comment

by:Amour22015
ID: 38376596
Great thanks
0
 

Author Comment

by:Amour22015
ID: 38376602
Sorry I meant:

Mlmcc = 200
GJParker = 50

Thanks
0
 
LVL 35

Expert Comment

by:James0628
ID: 38377462
So, you're actually setting the variable A to the _name_ of the field (the literal string "{TEMP_PWC_Report_SP_MAIN.minstrumenttype}"), not the value in that field.  Weird, but if that's what you want.

 James
0
 

Author Comment

by:Amour22015
ID: 38377583
James,

Did not know that was what I am doing?

Then I should be doing:
CStr({TEMP_PWC_Report_SP_MAIN.minstrumenttype});

Instead like GJParker mentions?

Thanks for pointing that out...
0
 
LVL 35

Expert Comment

by:James0628
ID: 38377806
Yep.  CStr will convert the numeric value in the field into a string.  It will use a default format for the number.  If you would like the number formatted a certain way (eg. with no decimal  places), there are options that you can add to the CStr arguments to specify the formatting.  Check the CR Help for the details.  Or just ask here.

 James
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

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

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses

607 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