Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Suppress when no record exists

Status
Not open for further replies.

RenaG

Programmer
May 3, 2011
132
US
Hi,

I am working in Crystal 2011.

I have a report that displays a patients immunization records. These records include flu (influenza), pneumococcal and TDAP. I don't want to see all past flu shots so I am suppressing based on date. Like this:

DateValue ({%Result}) <= date(Year (Today), 08, 01) and
{ObsDef.OBD_ID} = 24006 //Date of Influenza Injection

This works great until I run the report on a patient who doesn't have any flu shot records. Then get this error:
Bad date format string.

I added this to the conditional suppression but it didn't help:
if not(isnull({%Result})) then

How I get around patients who don't have a flu shot record to suppress?

TIA!
~RLG
 
Try this:

IsNull({%Result} or
(DateValue ({%Result}) <= date(Year (Today), 08, 01) and
{ObsDef.OBD_ID} = 24006 //Date of Influenza Injection)

Please note where I've put the parentheses - it won't work without them!

-Dell

DecisionFirst Technologies - Seven-time SAP BusinessObjects Solution Partner of the Year
 
Hi Dell,

Thank you for a quick reply. I modified my formula just as you suggested and I still get the "bad date format string" error. When I click ok, the suppress formula is displayed and the DateValue({%Result}) is highlighted.

BTW - %Result is in a text/string format but it is a date looking like this when displayed on the report:
10/24/2012

~RLG
 
This sounds like it might be a data issue to me. Could you post the formula for {%Result} please?

-Dell

DecisionFirst Technologies - Seven-time SAP BusinessObjects Solution Partner of the Year
 
I got the solution. I put an IsDate test at the beginning of the formula like this:

isnull({%Result}) or
(IsDate ({%Result}) and DateValue ({%Result}) <= date(Year (Today), 08, 01) and
{ObsDef.OBD_ID} = 24006) //Date of Influenza Injection

When I ran the report for a patient that didn't have an flu vaccine it worked just fine. I also removed the isnull test and it still works.

But, just because you asked [smile], here is the formula for %Result:

ISNULL(dbo.fn_GetObsResult(Observe.OBX_ID),'')

Thanks for your help! This forum is the best resource around!!!

~RLG
 
Ahh! That's why the value is never null! And the blank string that this returns when the field is null can't be converted to a date and that's what was causing your error.

-Dell

DecisionFirst Technologies - Seven-time SAP BusinessObjects Solution Partner of the Year
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top