Skip to Content
Former Member
May 11, 2010 at 04:55 PM

OR in "parameter1 OR parameter2" behaves like AND


I wrote a report using parameters for selecting data to be displayed in the report.

One parameter is StudentID, which is 9 numeric characters as a string. As a user data entry validation, I set both Max Length and Min Length of StudentID to 9.

Student ID most reliably pins down a student. However, users using the report may sometimes do not know a student's ID, so I provide the Firstname and Lastname parameters as an alternative.

In the Select Expert, the code is:

{FIRST_NAME} = UpperCase({?Firstname}) and 
{LAST_NAME} = UpperCase({?Lastname})
) OR
{STUDENT_ID} = {?StudentID}

When run the report, the report runs OK if only student ID is entered and first name and last name are left blank. However, if first name and last name are entered and student ID is left blank, the report won't let you go, and says the minimum length for this field is 9. The report won't run until you have entered 9 digits in addition to first and last names.

I found that I can get around this by removing the settings of Min Length and Max Length are removed. But that also gives up user entry validation.

What it appears to me is that Crystal Report checks ID length without bother to see the OR there. What my data selection code expects of it is to be aware of the OR first and check ID length only when necessary.

Or is there a way to get around this, and get to select data either by name or by ID, and still get the ID length validated when ID is used for data selection? (I am using Crystal Report Version 11.)

Thanks for help!