Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Display selected values NOT found in db, on a page Post Reply Post New Topic
Page  of 2 Next >>
Author Message
culov
Newbie
Newbie


Joined: 11 Dec 2009
Online Status: Offline
Posts: 6
Quote culov Replybullet Topic: Display selected values NOT found in db, on a page
    Posted: 11 Dec 2009 at 3:08pm
I have a view that displays a list of notes that have not been signed by a doctor.  Some doctors have signed all their notes and do not appear in this view.  I am using Crystal reports 11 and filtering the view by date.  I have imported a list of values for doctors, so that ALL doctors, not just those with unsigned notes, are readily available to select for the report.

What is happening currently, is if I select a doctor who has unsigned notes, the report will display all his unsigned notes on a page.  However, if I select a doctor who has no unsigned notes, he doesn't get a page in the report.  What I want, is for ALL doctors who I select to have their own page in the report.  If the view yields no unsigned notes for his doctor, then his page should be blank where the unsigned notes information would have gone.

This has been bothering me for weeks.  THANK YOU SO MUCH!
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 14 Dec 2009 at 6:19am
your data is currently using an innner join, which only displays entries that match in both tables. Since you want all doctors, regardless of # of notes unsigned, you would want to change the join to an outer join.
 
Go to Database Expert, Links and right click on the line that links the two table together, select Either of the Left or Right Outer joins and see if the report is the way you want, if not try the other join.  I can't figure out how CR determines the right from the left join, so I have to experiment.
 
Mostly my reports come from stored procedures where it is easy to determine the join type.
 
HTH
IP IP Logged
culov
Newbie
Newbie


Joined: 11 Dec 2009
Online Status: Offline
Posts: 6
Quote culov Replybullet Posted: 14 Dec 2009 at 3:26pm
Thanks for the response, but it didn't solve my problem.

I tried using an outer join instead of an inner join and I got the same result:  When I select a doctor who does have unsigned notes, he gets a page showing the results.  good.  the problem is, when i select a doctor who DOES NOT have any unsigned notes (after i did the right join, his name IS in the database), and i run the report, this doctor does not get a page.

i think my issue may have less to do with the query and more to do with an option i have to select.  in other words, i want a print to page for all doctors i select whether or not any unsigned notes were found for this docotor.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 14 Dec 2009 at 6:52pm
IP IP Logged
culov
Newbie
Newbie


Joined: 11 Dec 2009
Online Status: Offline
Posts: 6
Quote culov Replybullet Posted: 18 Dec 2009 at 2:31pm
I still havent been able to create the report that I need so let me be more descriptive.

I am doing an outer join so that the view has every doctor and every note, unsigned or signed.  unsigned notes have a status <10, and signed notes have a status = 10.

What I want is a report where I select as many doctors as I'd like, and then EVERY doctor that I selected from the list has a page in the report which displays his unsigned note status.  The nsigned note status would be a list of notes if the doctor has any unsigned notes, or a blank section of the doctor doesnt have any unsigned notes.

What the report is doing now is taking my selection and creating a page for every doctor who has unsigned notes (OP_NOTESTATUS < 10) and ignoring those doctors who only have notes with OP_NOTESTATUS = 10!  I feel as though I must be missing something really simple because the option to accomplish what I want could be easily done with a checkbox of some sort.

All I need is a page for every ?Doctor that I select on my list.

DBBlank:  your link was helpful, but my problem isnt quite the same.

Here's a little summary of my report as it stands:

Formula Fields: 
Date Range

cstr( {?StartingDate} ) + " to " + cstr( {?EndingDate} )

Doctor
{vw_DoctorNotes.Doctor}

Record Selection:
{vw_DoctorNotes.Doctor} = {?Doctor} and
({vw_DoctorNotes.ActivityDate}) in {?startingdate} to {?endingdate} and
{vw_DoctorNotes.OP_NOTESTATUS} < 10


Thank you so much!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 Dec 2009 at 2:39pm
The problem is basically the same.
Your crystal select statment is enforced after the joins turning an outer join into an inner join.
If you are limited to using crystal to solve this the easiest solution is to NOT use the select record statment but rather conditionally hide all the records you do not want to see. The report result looks the same but only less efficient than doing this in a SQL stored proc or view.
Make sense?


Edited by DBlank - 18 Dec 2009 at 2:40pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 Dec 2009 at 2:46pm
Left join into your doc table.
Group on the doc field (from the doc table)
Use the select statement of {table.Doctor} = {?Doctor}
Place the values you want to see on your details
Conditionally suppress the details row the same way you were selecting the data.
NOT ({vw_DoctorNotes.ActivityDate}) in {?startingdate} to {?endingdate} and {vw_DoctorNotes.OP_NOTESTATUS} < 10
Add a New page after GF1 (not onlastrecord)
 
If you have rights to making views or stored procedures you may be able to do this outside of crystal and use that as your source. The stored proc is easier for dynamic date fields like you are using because you can pass then straight to the sp.


Edited by DBlank - 18 Dec 2009 at 2:49pm
IP IP Logged
culov
Newbie
Newbie


Joined: 11 Dec 2009
Online Status: Offline
Posts: 6
Quote culov Replybullet Posted: 21 Dec 2009 at 3:28pm
Originally posted by DBlank

Left join into your doc table.
Group on the doc field (from the doc table)
Use the select statement of {table.Doctor} = {?Doctor}
Place the values you want to see on your details
Conditionally suppress the details row the same way you were selecting the data.
NOT ({vw_DoctorNotes.ActivityDate}) in {?startingdate} to {?endingdate} and {vw_DoctorNotes.OP_NOTESTATUS} < 10
Add a New page after GF1 (not onlastrecord)
 
If you have rights to making views or stored procedures you may be able to do this outside of crystal and use that as your source. The stored proc is easier for dynamic date fields like you are using because you can pass then straight to the sp.


Thank you, this was very helpful is pointing me in the right direction.  I do have the ability to make views and I also had a different approach that I was trying out.  First, allow me to ask you a question about the formula you wrote out. 

NOT ({vw_DoctorNotes.ActivityDate}), doesn't work because NOT expects a boolean.  I figured that you may have meant NOT ( ({vw_DoctorNotes.ActivityDate}) in {?startingdate} to {?endingdate}) but I tried that and what that returns is every unsigned note OUTSIDE of my range.

Even if I were to get this piece correct, I still haven't achieve what I need:  A page displayed with simply the page header (doctor's name and date range) with an empty details section if the doctor has no unsigned notes.  This piece here is actually the ONLY thing that I need.  I've had the report working before with everything except the blank details section for when no doctor's are found.

Is this simply impossible in crystal reports?  I've tried everything imaginable  without luck.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 22 Dec 2009 at 6:15am
It's not that it is not possible, it's just a matter of finding the right way. If you can build a view/stored proc, you can create the dataset in SQL and see the results, then you can set the view/stored proc to be the input for the report making much of this simpler.
 
your select statement could be something like:
select *
from doctors as d
 left join doctorNotes n on n.doctorid = d.doctorid
where n.ActivityDate between @startdate and @enddate
 
some of it is made up, not really knowing the data structure, but this select you could easily filter in CR to only include the doctors that you want (I would filter it in the SQL but passing the data into the proc/view is a bit more complex) AND would include the doctors that had no notes.
 
HTH
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Dec 2009 at 7:11am

Yes I did make an error in typing the formula and it should be as you deciphered.

Yes it is correct. If you use it in the select statement it gives you everything outside your date range, I want you to use it in the Section Expert Details section conditional Suppress. As you notes it returns a TRUE for everything outside your date range and hence will hide all those records leaving only the values you want as shown.
Since you grouped on the doc name all the doc names are still there.
 
GH1=Doc Name (from Doc table)
Details= your fields re: the notes (conditionally suppressed using the NOT statement)
GF1=Use new page after conditionally as NOT ONLASTRECORD (will give you a page break per doc)
 
make sense?
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.029 seconds.