Solved

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

Posted on 2004-03-23
7
607 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
[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
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
[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

 
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

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. …
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

729 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