Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Assistance needed Post Reply Post New Topic
Page  of 2 Next >>
Author Message
Hammer
Newbie
Newbie


Joined: 06 Dec 2012
Online Status: Offline
Posts: 10
Quote Hammer Replybullet Topic: Assistance needed
    Posted: 06 Dec 2012 at 11:39am
I apologize in advance if this has been brought up before but i couldnt find a thread discussing it.
I have a report that includes employee phone #'s. An employee can have a Home # or a Cell # or both.
I only want the report to show me cell numbers but if they dont have a cell # I need the home # to show.
when I "tell" crystal to only show cell it obviously excludes all employees that have home and I lose the few employees that only have a cell.
How can i make this work? I tried using an If Then Else but it doesnt work


Edited by Hammer - 06 Dec 2012 at 11:42am
IP IP Logged
junkbox
Newbie
Newbie


Joined: 07 Nov 2012
Online Status: Offline
Posts: 17
Quote junkbox Replybullet Posted: 06 Dec 2012 at 1:00pm
off the cuff I'd say use a formula:

@PhoneCheck

if isnull({table.cellphone}) or {table.cellphone}="" then {table.homephone}
else
{table.cellphone}

drag that to your details band where you want the phone field to display
IP IP Logged
Hammer
Newbie
Newbie


Joined: 06 Dec 2012
Online Status: Offline
Posts: 10
Quote Hammer Replybullet Posted: 06 Dec 2012 at 4:10pm
I dont follow; here is the table that i am pulling my data from:

PERSON_ID

NAME

LAST_NAME

FIRST_NAME

MIDDLE_NAME

MIDDLE_INITIAL

AKA

EMPLOYEE_ID

PHONE_CODE

PHONE

AREA_CODE

PHONE_NO

EXTENSION

PHONE_NUMBER

COUNTRY_CODE

COUNTRY

IS_UNLISTED

COMMENTS

 
phone_code is where it stores what type of phone the phone_no is.
home or cell. how can i show only cell but if no cell then show home
IP IP Logged
junkbox
Newbie
Newbie


Joined: 07 Nov 2012
Online Status: Offline
Posts: 17
Quote junkbox Replybullet Posted: 06 Dec 2012 at 4:49pm
So is the following what the output would look like if two are available (both home and cell) with no suppression?

FIRST_NAME    LAST_NAME   PHONE_CODE   PHONE_NO
John                Smith             Cell                   123.456.7890
John                Smith             Home                456.789.0123

?

Also please define what the value is for {PHONE} I understand {PHONE_CODE} and assume {PHONE_NO} is the actual number.

EDIT: actually give me a definition of all the PHONE_* fields.



Edited by junkbox - 06 Dec 2012 at 4:52pm
IP IP Logged
Hammer
Newbie
Newbie


Joined: 06 Dec 2012
Online Status: Offline
Posts: 10
Quote Hammer Replybullet Posted: 06 Dec 2012 at 5:09pm
yes that is correct. i only want to see the John Smith Cell. But if John Smith didnt have a cell i would need his home # to show up.
 
Phone_code is the type of phone: cell, home, fax, work
Phone is the string that matches up to the code
Phone_no is the 6 digits of the number
Phone_number is the full number including area code
IP IP Logged
junkbox
Newbie
Newbie


Joined: 07 Nov 2012
Online Status: Offline
Posts: 17
Quote junkbox Replybullet Posted: 06 Dec 2012 at 5:31pm
gotchya, so {PHONE} is essentially an ID

1="Cell"
2="Home"
3="Fax"

or

C="Cell"
h="Home"

etc.


?


Edited by junkbox - 06 Dec 2012 at 5:32pm
IP IP Logged
Hammer
Newbie
Newbie


Joined: 06 Dec 2012
Online Status: Offline
Posts: 10
Quote Hammer Replybullet Posted: 06 Dec 2012 at 5:32pm
yes
IP IP Logged
junkbox
Newbie
Newbie


Joined: 07 Nov 2012
Online Status: Offline
Posts: 17
Quote junkbox Replybullet Posted: 06 Dec 2012 at 6:24pm
Does {PHONE} have a value if say Home phone isn't there?
Meaning can john smith have a {PHONE}=2 but {PHONE_NO}=NULL or ""?
I'm asking if the {PHONE} 1-5 are always present or if the data source only knows what it gets

John Smith
{PHONE}=1 {PHONE_CODE}="Cell" {PHONE_NO}="123-4567"
{PHONE}=2 {PHONE_CODE}="Home" {PHONE_NO}=NULL
{PHONE}=3 {PHONE_CODE}="Fax" {PHONE_NO}="789-0123"
{PHONE}=4 {PHONE_CODE}="Work" {PHONE_NO}="456-7890"

OR

{PHONE}=1 {PHONE_CODE}="Cell" {PHONE_NO}="123-4567"
{PHONE}=3 {PHONE_CODE}="Fax" {PHONE_NO}="789-0123"
{PHONE}=4 {PHONE_CODE}="Work" {PHONE_NO}="456-7890"

where home doesn't exist in the DB at all cause it wasn't created.
IP IP Logged
Hammer
Newbie
Newbie


Joined: 06 Dec 2012
Online Status: Offline
Posts: 10
Quote Hammer Replybullet Posted: 07 Dec 2012 at 12:05am
Every Emp must have a home phone_no but the field can be blank. If you don't enter a home phone it will be an empty field.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 07 Dec 2012 at 4:29am
I would do the following:
 
1.  Add a second copy of this table to the report in the Database Expert.  When you add a table that is already in the report, Crystal will ask if you want to alias it and then add it with "_1" at the end of the table name.  So, if the table name is PersonInfo, you'll see that table and PersonInfo_1.
 
2.  Link from {PersonInfo.PERSON_ID} to {PersonInfo_1.PERSON_ID}.  Make the link a Left Outer Join.
 
3.  Edit the Selection Criteria for the report.  You'll need to edit the formula instead of just selecting fields.  In addition to any other criteria in the formula, you'll have something like the following:
 
{PersonInfo.PHONE_CODE} = "Home" and
(IsNull({PersonInfo_1.PERSON_ID}) OR
 {PersonInfo_1.PHONE_CODE} = "Cell")
 
Note the parentheses in red - these are required to make this work correctly!
 
4.  Create a formula that looks like the following:
 
If IsNull({PersonInfo_1.PHONE_NO}) or {PersonInfo_1.PHONE_NO} = "" then
  {PersonInfo.PHONE_NO}
else
  {PersonInfo_1.PHONE_NO}
 
-Dell
IP IP Logged
Page  of 2 Next >>
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.012 seconds.