Solved

If ... Then Select... Else Syntax Problems

Posted on 2004-03-23
7
605 Views
Last Modified: 2008-02-26
I have a formula field that I had to change around a bit and it no longer gives me the results I want.  My old formula was comprised of this:

-------

if {JC1_JobMaster.Comment} like "*CORNER*" or {JC1_JobMaster.Comment} like "*DETACHED*" then
select {JC1_JobMaster.SortField}
       
        case "SADDLE M" : 140
        case "SUGAR" :  345
        case "SADDLEROCK" : 80
        case "SAVANNAH" : 43
        case "PARKFIELD" : 71.85

        default: 0

--------

On the report, all values for this field would show up as 0, or as one of the numbers from the case statement.  An important thing to know is that the line for default of 0, is not why 0 shows up.  Meaning, that if the condition is false, it still shows up as a 0 on the report.

Now when I changed my formula to this:

--------

if {JC_90_UDF_Job_Cost_Header.Trcorner} like "Y" then
select {JC1_JobMaster.SortField}
       
        case "SADDLE M" : 140
        case "SUGAR" :  345
        case "SADDLEROCK" : 80
        case "SAVANNAH" : 43
        case "PARKFIELD" : 71.85

        default: 0

---------

I no longer get a 0 showing up when the if statement is false.  I just get a blank field, and I need it to be 0.  I know it should probably be something like this:

If (condition) then
select

...

else
0

But I can't figure out the syntax.

Any help would be appreciated, and I'm curious to know if anyone can explain why the 0 values stopped showing up.

Thanks!
0
Comment
Question by:Mourdekai
7 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 10659586
Hello Mourdekai,

it shouldbe something like this:
 
 If (condition) then
 (
select
 
 ...
 )
 else
 0



Pete
0
 
LVL 8

Author Comment

by:Mourdekai
ID: 10659621
Pete,

if {JC_90_UDF_Job_Cost_Header.Trcorner} like "Y" then
(select {JC1_JobMaster.SortField}
       
        case "SADDLE M" : 270
        case "SUGAR" :  215
        case "SADDLEROCK" : 280
        case "SAVANNAH" : 430
        case "PARKFIELD" : 701.85

        default: 0;)
else
0


Does NOT work, any other suggestions?
0
 
LVL 8

Author Comment

by:Mourdekai
ID: 10659730
I figured it out, this is what I needed before my if

if isnull({JC_90_UDF_Job_Cost_Header.Trcorner}) then 0
else
if {JC_90_UDF_Job_Cost_Header.Trcorner} like "Y" then
select {JC1_JobMaster.SortField}
...
...

0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 28

Expert Comment

by:bdreed35
ID: 10659778
Try this:

if instr({JC_90_UDF_Job_Cost_Header.Trcorner},"Y")>0 then
(select {JC1_JobMaster.SortField}
       
        case "SADDLE M" : 270
        case "SUGAR" :  215
        case "SADDLEROCK" : 280
        case "SAVANNAH" : 430
        case "PARKFIELD" : 701.85

        default: 0;)
else
0
0
 
LVL 8

Author Comment

by:Mourdekai
ID: 10659876
bdreed35, thanks for trying but that doesn't work either.  See my above post for the solution I found.
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 10694322
Closed, 172 points refunded.
PashaMod
Community Support Moderator
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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