Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: IF Then ELse If Question.... Post Reply Post New Topic
Author Message
Seabass
Newbie
Newbie
Avatar

Joined: 06 Jun 2009
Location: United States
Online Status: Offline
Posts: 32
Quote Seabass Replybullet Topic: IF Then ELse If Question....
     Posted: 28 Mar 2011 at 1:27am
Good morning !
 
Looking at a formula where it is looking at a string and return a category based on the criteria setup.... The formulas look like this:
 
IF {table.column} LIKE "*Grease*" THEN "Lube & Filter"
ELSE IF {table.column} LIKE "*Oil*" THEN "Lube & Filter"
ELSE IF {table.column} LIKE "*Filter*" THEN "Lube & Filter"
ELSE IF {table.column} LIKE "Eye Wash" THEN "Eye Wash Stations"
ELSE IF {table.column} LIKE "Eyewash" THEN "Eye Wash Stations"
 
ELSE IF {table.column} LIKE "Insp" THEN "Inspections"
ELSE IF {table.column} LIKE "Check" THEN "Inspections" 
 
ELSE IF {table.column} LIKE "Clean" THEN "Cleaning PMs"
ELSE IF {table.column} LIKE "Wash" THEN "Cleaning PMs"
ELSE IF {table.column} LIKE "Flush" THEN "Cleaning PMs"
 
ELSE IF {table.column} LIKE "*Fire*" THEN "Safety"
ELSE IF {table.column} LIKE "*Saftey*" THEN "Safety"
ELSE IF {table.column} LIKE "*Safety*" THEN "Safety"

Else "Other"
 
The problem i am running into is that when i run the report, i have records in the "Lube & Filter" and "Eye Wash Stations" but nothing in the other category (Inspections, Cleaning PMs & Safety).... I do know that some records should fall into these category....
 
I tried ot change the way the formulas is written, adding OR and AND and removing some ELSE IF... I am not a coder and keep having some error thus cannot run it....
 
Any help on this would be appreciated....
 
Thanks in advance.
 
Seabass
 
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 28 Mar 2011 at 3:07am
How about just making it a series of ifs....like:
 
local stringvar smsg := "";

IF {table.column} LIKE "*Grease*" THEN smsg := "Lube & Filter";
IF {table.column} LIKE "*Oil*" THEN smsg := "Lube & Filter";
IF {table.column} LIKE "*Filter*" THEN smsg := "Lube & Filter";

IF {table.column} LIKE "Eye Wash" THEN smsg := "Eye Wash Stations" ;
IF {table.column} LIKE "Eyewash" THEN smsg := "Eye Wash Stations" ;
 
IF {table.column} LIKE "Insp" THEN smsg := "Inspections";
IF {table.column} LIKE "Check" THEN smsg := "Inspections"  ;

IF {table.column} LIKE "Clean" THEN smsg := "Cleaning PMs" ;
IF {table.column} LIKE "Wash" THEN smsg := "Cleaning PMs" ;
IF {table.column} LIKE "Flush" THEN smsg := "Cleaning PMs" ;
 
IF {table.column} LIKE "*Fire*" THEN smsg := "Safety";
IF {table.column} LIKE "*Saftey*" THEN smsg := "Safety";
IF {table.column} LIKE "*Safety*" THEN smsg := "Safety";

IF smsg = "" THEN smsg := "Other";

smsg

IP IP Logged
Seabass
Newbie
Newbie
Avatar

Joined: 06 Jun 2009
Location: United States
Online Status: Offline
Posts: 32
Quote Seabass Replybullet Posted: 31 Mar 2011 at 9:17am
sorry it took a few days to reply... thank you, put it in and it works !!!!
 
Appreciate your assistance
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum