Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Can't restrict on a sometimes null field Post Reply Post New Topic
Author Message
TJ1776
Newbie
Newbie
Avatar

Joined: 12 Dec 2010
Location: United States
Online Status: Offline
Posts: 2
Quote TJ1776 Replybullet Topic: Can't restrict on a sometimes null field
     Posted: 12 Dec 2010 at 2:37pm
Crystal Reports 11
MSSQL 2000 DB

Vehicle maintenance database:

Attempting to write a two-table report that will show vehicle numbers (from Table1) and a *subset* of vehicle inspections (from Table2). Not all vehicles in Table1 have inspections listed in Table2, but my report needs to show all vehicles from Table1 along with a subset (if any) of inspections listed in Table2. Example:

Table1:
vehcile_number
3556
3557

Table2:
vehicle_number Inspection
3556           STATE
3556           EMISSONS
3556           SAFETY

I've joined Table1 and Table2 on vehicle_number with:
Join Type: Left Outer Join
Enforce Join: No Enforcement
Link Type: =

Restrictions:
With no restrictions, output looks as expected, below.

vehicle_number Inspection
3556           STATE
3556           EMISSIONS
3556           SAFETY
3557

However, I want to restrict SAFETY inspections from the report. When I restrict thusly: Inspection <> "SAFETY", the SAFETY inspection is restricted from the report (OK), but the vehicles with *no* inspecitons are also restricted from the report as below (NOT OK).

vehicle_number Inspection
3556           STATE
3556           EMISSIONS

It's missing vehicle number 3557 (with NULL value in the Inspection field)

How do I write the restrction so that the SAFETY inspection is excluded while including those vehicles with *no* inspections? Any help is greatly appreciated.

Jeff
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 13 Dec 2010 at 3:56am
using crystal only there is no nice way to do this.
You can write a crystal command if needed but can you just suppress the 'safety' inspection rather than exclude it?


Edited by DBlank - 13 Dec 2010 at 3:57am
IP IP Logged
TJ1776
Newbie
Newbie
Avatar

Joined: 12 Dec 2010
Location: United States
Online Status: Offline
Posts: 2
Quote TJ1776 Replybullet Posted: 13 Dec 2010 at 6:26am
Dblank,
 
I found an answer that worked on another forum.  I added the following formula:
 
(if isnull({Table2.inspection}) then true else {TABLE2.inspection} <> "safety")
 
However, I like you're idea of supressing the safety inspection.  If you have a quick explanation of how/where to invoke the suppress feature, that would be great.  Most of my report writing experience (I'm between beginner and intermediate) is just writing the sql select statements, and I'm just starting to learn Crystal with all of its bells and whistles.
 
Thanks for the input.

Jeff
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 13 Dec 2010 at 6:38am

The solution you have found will work only if every time table 2 has 'safety' it for a vehicle number it also has some other row (non safety) in table 2. otherwise it will omit that vehicle number from the report and why I did not recommend it.

suppressing is pretty easy. Just note that suprressing rows does not exlcude them from counts. YOu have to do that with Variable formulas or Running Totals.
You can suppress a field by right clicking on it and selecting
Format field
common tab
X-2 formula box next to Suppress
insert your formula (boolean formula with a TRUE doing a suppression)
e.g. {TABLE2.inspection} = "safety"
or you can suppress section in a similar way using teh section expert.
 


Edited by DBlank - 13 Dec 2010 at 6:40am
IP IP Logged
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