Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: probelm using select case Post Reply Post New Topic
Author Message
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Topic: probelm using select case
    Posted: 05 Sep 2012 at 2:41am
when I run this report using the select case code below it tells me that every employee is of asian descent. Am I doing something wrong here?

Thank you in advance for your help!


//A    Asian
//B    African American
//F    Foreign National
//H    Hispanic
//I    Native American/Alaskan Native
//M    Middle Eastern
//O    Other
//P    Native Hawaiian or Pacific Islander
//T    Two or More Races
//Undefined    Undefined
//W    Caucasian

Select {CEthnicity.ethnicity}
    case "A"
    :"Asian"
    case "B"
    :"African American"
    case "F"
    :"Foreign National"
    case "H"
    :"Hispanic"
    case "I"
    :"Native American/Alaskan Native"
    case "M"
    :"Middle Eastern"
    case "O"
    :"Other"
    case "P"
    :"Native Hawaiian or Pacific Islander"
    case "T"
    :"Two or More Races"
    case "Undefined"
    :"Undefined"
    case "W"
    :"Caucasian"
    Default
    :"Undefined";

IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 05 Sep 2012 at 3:55am
What error are you getting?  If you're not getting any data, try taking the semi-colon (;) off the end of it. 
Personally, I tend to use the Crystal Syntax "Switch" statement instead of select/case.  It would look something like this:
 
Switch(
  IsNull({CEthnicity.ethnicity}), 'Undefined',
  {CEthnicity.ethnicity} = 'A', 'Asian',
  {CEthnicity.ethnicity} = 'B', 'African American',
  ...
  {CEthnicity.ethnicity} = 'W', 'Caucasian,
  true, 'Undefined'}
 
-Dell
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 05 Sep 2012 at 4:08am
thank you for your quick reply. i tried removing the semi colon from the end of the code and still got the same result. i changed out the code completely and tried the "switch" statement and that is still giving me the same result.

it is returning data however it is telling me that every employee is Asian instead of going through the whole statement and showing their true ethnicity.

any thoughts? this is the current code from the report.

Switch(
  IsNull({CEthnicity.ethnicity}), 'Undefined',
    {CEthnicity.ethnicity} = 'A', 'Asian',
    {CEthnicity.ethnicity} = 'B', 'African American',
    {CEthnicity.ethnicity} = 'F', 'Foreign National',
    {CEthnicity.ethnicity} = 'H', 'Hispanic',
    {CEthnicity.ethnicity} = 'I', 'Native American/Alaskan Native',
    {CEthnicity.ethnicity} = 'M', 'Middle Eastern',
    {CEthnicity.ethnicity} = 'O', 'Other',
    {CEthnicity.ethnicity} = 'P', 'Native Hawaiian or Pacific Islander',
    {CEthnicity.ethnicity} = 'T', 'Two or More Races',
    {CEthnicity.ethnicity} = 'U', 'Undefined',
    {CEthnicity.ethnicity} = 'W', 'Caucasian',
  true, 'Undefined')
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 05 Sep 2012 at 4:34am
I would put the  {CEthnicity.ethnicity} field on the report and see what data is being returned in it just to validate that the various values are there.
 
-Dell
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 05 Sep 2012 at 4:47am
thank again dell, here is what i am getting returned when i just use {CEthnicity.ethnicity}

LastName  FirstName  Annual Salary  FT/PT

Heflin Catherine A F 




LastName  FirstName  Annual Salary  FT/PT

Hill Justin A M 




LastName  FirstName  Annual Salary  FT/PT

Hill Natasha A F 




LastName  FirstName  Annual Salary  FT/PT














The 'A' (Asian) is returning for every employee. so i'm assuming it's the actual database that is incorrect?  when i run this as a sql query it returns the correct data ie employees lastname, firstname and ethnicity.
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 05 Sep 2012 at 5:01am
i figured it out. i was actually calling the wrong table. we'll chalk this one up to a rookie mistake ;)

thank you for your help!

now i just need to figure out how to stop the header from repeating and line up the cells under it.
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.