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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Querying for nulls in a selection

Status
Not open for further replies.

xp8103

Programmer
May 22, 2001
62
US
CR 8.5 (I'm stuck with it at the moment) I am either stoopid or simply having a brain cramp. But I'll be darned if I can figure out how to simply, include records where a parameter value might be null?

In this report, I have two parameter elements, one a number and the other a letter. In my dataset, there will ALWAYS be a number. There WON'T always be a letter.
My selection criteria currently look like:
(If {?pTheTitleAlpha} <> "ALL"
Then
{vTitleAndSection.Title_Alpha} = {?pTheTitleAlpha}
Else
{vTitleAndSection.Title_Alpha} Like "*") and
{vTitleAndSection.Title} = {?pTheTitle}

I've tried everything in that IF statement, IsNull, = "", = " ". I've added "ALL" as one of the possible values for the parameter. But at BEST I get ONLY those records where the letter actually has a value, not the ones where it's null.
 
Can you please show samples of your two fields {vTitleAndSection.Title_Alpha} and {vTitleAndSection.Title}? Also you talk about a null parameter values, but I think you really are talking about nulls only in your data.

What are each of the two parameters supposed to do? Do you only want to include nulls whenever "All" is not selected?

If I'm following you, try this:

(
If {?pTheTitleAlpha} <> "ALL" Then
{vTitleAndSection.Title_Alpha} = {?pTheTitleAlpha} Else
If {?pTheTitleAlpha} = "ALL" Then
true
) and
{vTitleAndSection.Title} = {?pTheTitle}

-LB
 
Try this:

({?pTheTitleAlpha} = "ALL" OR {vTitleAndSection.Title_Alpha} = {?pTheTitleAlpha})
AND {vTitleAndSection.Title} = {?pTheTitle}

If {?pTheTitleAlpha} is "ALL", return TRUE and go onto the next comparison. Otherwise, compare {vTitleAndSection.Title_Alpha} to {?pTheTitleAlpha} before moving onto the next comparison.
 
If you want to check to see if the parameter is NULL instead of "ALL"....

(ISNULL({?pTheTitleAlpha}) OR {vTitleAndSection.Title_Alpha} = {?pTheTitleAlpha})
AND {vTitleAndSection.Title} = {?pTheTitle}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top