Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: Trying to get a proper record selection Post Reply Post New Topic
Author Message
Alb2tead
Newbie
Newbie
Avatar

Joined: 06 Nov 2012
Location: United States
Online Status: Offline
Posts: 13
Quote Alb2tead Replybullet Topic: Trying to get a proper record selection
    Posted: 07 Feb 2013 at 9:58am
I am trying to get a list of physicians to monitor their credentials.  This is the formula that I am using for the record selection:
 
IsNull({STAFF_TERMINATION_HISTORY.TERMINATION_DATE})
And
{STAFF_ENROLLMENT_HISTORY.PRACTITIONER_CATEGORY_VALUE} In ["PHYSICIAN", "PSYCHIATRIST"]
And
{STAFF_ENROLLMENT_HISTORY.STAFFID} <> "000004"

OR
{SITE_SPECIFIC_STAFF_ENROLLMENT.REGISTRATION_DATE} > {STAFF_TERMINATION_HISTORY.TERMINATION_DATE}
And
{STAFF_ENROLLMENT_HISTORY.PRACTITIONER_CATEGORY_VALUE} In ["PHYSICIAN", "PSYCHIATRIST"]
And
{STAFF_ENROLLMENT_HISTORY.STAFFID} <> "000004"
 
The problem that I am having is that the formula directly after the "or" is causing people to show up that are no longer employed.  Our system tracks the termination date and the registration date and sometimes people have four or five stints of employment.  I am only wanting if the registration date is after the latest termination, but this formula pulls for all terminations.  How can I recode the formula to get the desired results.
 
 
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 07 Feb 2013 at 11:45am
You'll need to use parentheses to "group" the two different sets of criteria.  Something like this:
 
(
IsNull({STAFF_TERMINATION_HISTORY.TERMINATION_DATE})
And
{STAFF_ENROLLMENT_HISTORY.PRACTITIONER_CATEGORY_VALUE} In ["PHYSICIAN", "PSYCHIATRIST"]
And
{STAFF_ENROLLMENT_HISTORY.STAFFID} <> "000004"
)
OR
(
{SITE_SPECIFIC_STAFF_ENROLLMENT.REGISTRATION_DATE} > {STAFF_TERMINATION_HISTORY.TERMINATION_DATE}
And
{STAFF_ENROLLMENT_HISTORY.PRACTITIONER_CATEGORY_VALUE} In ["PHYSICIAN", "PSYCHIATRIST"]
And
{STAFF_ENROLLMENT_HISTORY.STAFFID} <> "000004"
)
 
-Dell
IP IP Logged
Alb2tead
Newbie
Newbie
Avatar

Joined: 06 Nov 2012
Location: United States
Online Status: Offline
Posts: 13
Quote Alb2tead Replybullet Posted: 08 Feb 2013 at 3:32am
Thanks for you help, but this gave the same results.
 
What is happening is the part of the code:
 
{SITE_SPECIFIC_STAFF_ENROLLMENT.REGISTRATION_DATE} > {STAFF_TERMINATION_HISTORY.TERMINATION_DATE} is returning multiple values which I have suppressed.  But the newest value is still showing up on the report, even if the person is no longer with us.  What I am trying to do is get the newest registration date be greater than the newest termination date, if that makes sense.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 08 Feb 2013 at 3:54am
First, you need to check the joins.  Go to the Database Expert and look at the way your tables are linked together.  You need to make sure that the link TO
STAFF_TERMINATION_HISTORY is a left outer join.  This link needs to be FROM the SITE_SPECIFIC_STAFF_ENROLLMENT table or, if you have it, some sort of STAFF master table which would also be linked to SITE_SPECIFIC_STAFF_ENROLLMENT.  The direction and configuration of the joins is important!
Then simplify the selection criteria:
 
(
IsNull({STAFF_TERMINATION_HISTORY.TERMINATION_DATE})
or
{SITE_SPECIFIC_STAFF_ENROLLMENT.REGISTRATION_DATE} > {STAFF_TERMINATION_HISTORY.TERMINATION_DATE}
)
 
And
{STAFF_ENROLLMENT_HISTORY.PRACTITIONER_CATEGORY_VALUE} In ["PHYSICIAN", "PSYCHIATRIST"]
And
{STAFF_ENROLLMENT_HISTORY.STAFFID} <> "000004"
 
-Dell
IP IP Logged
Alb2tead
Newbie
Newbie
Avatar

Joined: 06 Nov 2012
Location: United States
Online Status: Offline
Posts: 13
Quote Alb2tead Replybullet Posted: 12 Feb 2013 at 4:33am
I did it how said and I am pulling more people because the
IsNull({STAFF_TERMINATION_HISTORY.TERMINATION_DATE}) is on an or and does not have the "Physician" "Psychiatrist" drill-down.  Is there any way to get the most recent  {SITE_SPECIFIC_STAFF_ENROLLMENT.REGISTRATION_DATE} and most recent {STAFF_TERMINATION_HISTORY.TERMINATION_DATE}.
 
After re-linking the tables as you described and used my original formula, (because the new one as stated above came back with people outside the parameter) it gave the same people as before re-linking the tables.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 12 Feb 2013 at 5:32am
This is a tough one to do just linking tables.  How good are you SQL Skills?  In this particular situation I usually base the report on a Command (SQL Select statement that I've written) instead of on linked tables.
 
-Dell
IP IP Logged
Alb2tead
Newbie
Newbie
Avatar

Joined: 06 Nov 2012
Location: United States
Online Status: Offline
Posts: 13
Quote Alb2tead Replybullet Posted: 12 Feb 2013 at 5:37am

To be honest, I have never done an SQL.  I will look at some informations to see if I can figure it out.  Most of my Crystal Report skills are self taught, so I will see if there is some information to help.  If I get stuck, I will post.  Thanks for you help

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.