Question : Optional parameters

My where clause is as follows:

WHERE (Latitude IS NOT NULL) AND
                                                (@ShowOnline = 0 OR [Online] = 1)
                                                AND (@ShowOnline = 1 OR longitude between @lon1 and @lon2 and latitude between @lat1 and @lat2)
                                                --AND (@ShowOnline = 1 OR latitude is null or longitude between @lon1 and @lon2 and latitude between @lat1 and @lat2)
                                                AND (@Keywords = '' OR (AboutMe LIKE '%' + @Keywords + '%' OR
                                                   Interests LIKE '%' + @Keywords + '%'))
                                                AND (@ethnicity = 'Any' OR ethnicity = @ethnicity)
                                                AND (@Username = '' OR Username LIKE '%' + @Username + '%')

However, anyone without a lat/long can't be found by the username criteria, so what we need to do is forget all critiera if @Username != '', otherwise we need to run the other bulk of the query, so in psudocode it would look like:

IF @Username != '' then
(@Username = '' OR Username LIKE '%' + @Username + '%')
else
 (Latitude IS NOT NULL) AND
                                                (@ShowOnline = 0 OR [Online] = 1)
                                                AND (@ShowOnline = 1 OR longitude between @lon1 and @lon2 and latitude between @lat1 and @lat2)
                                                --AND (@ShowOnline = 1 OR latitude is null or longitude between @lon1 and @lon2 and latitude between @lat1 and @lat2)
                                                AND (@Keywords = '' OR (AboutMe LIKE '%' + @Keywords + '%' OR
                                                   Interests LIKE '%' + @Keywords + '%'))
                                                AND (@ethnicity = 'Any' OR ethnicity = @ethnicity)

Sorry about the formatting

Answer : Optional parameters

Do you have the CONVERT NULL DATES TO DEFAULT option set?

Open the report
Click FILE --> REPORT OPTIONS
Is the option CONVERT DATABASE VALUES TO DEFAULT checked?

Is the database actually returning that date?

You could also suppress the value with a formula
Right click the field
Click FORMAT FIELD
Click the COMMON TAB
Click the FORMULA BUTTON to the right of suppress
{YourField} = Date(1900,1,1)

mlmcc
Random Solutions  
 
programming4us programming4us