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!

IF x or y or z Then... ELSE I don't care?

Status
Not open for further replies.

zhac

IS-IT--Management
Nov 2, 2001
4
US
I'm trying to create a parameter field, where the user should be inputting a 1,2,3, or 4. However, they may also leave it Null to include all of the above.

The way we currently have it written is like so:

(IF {?Minimum Class} <= &quot;4&quot;
then
{Equipment.Class}<= {?Minimum Class}
else
{Equipment.Class} <= &quot;5&quot;)

...which says &quot;If the parameter entered is <= 4, then leave the 'minimum class' as the parameter entered. Otherwise, &quot;minimum class' is <= 5.

Trouble is, when the user doesn't enter a number (which means they want to include everything), we get inaccurate data...how would I write the last part of this?:

(IF {?Minimum Class} <= &quot;4&quot;
then
{Equipment.Class}<= {?Minimum Class}
else
&quot;INCLUDE EVERYTHING!!!&quot;
 
Try this:

(If {?Minimum Class} <= &quot;4&quot;
Then
{Equipment.Class} <= {?Minimum Class}
Else
If
IsNull({?Minimum Class})
Then
{Equipment.Class} <= &quot;5&quot;)

 
Are you going to use this in a record selection formula??

If so, what you are proposing is very slow since it would be evaluated on Client-side

What I do in your case depends on the type of variable and it would seem that you are using a numeric parameter

So in this case I would use 2 parameters

{?Start Class} which has the default value set to 0
{?End Class} which has the default value set to 5 (or a
ridiculous high number)

If the user wanted one class then they would just enter the same number in both parameters

In the recordSelection formula you would have

{Equipment.Class} >= {?Start Class} and
{Equipment.Class} <= {?End Class}

If the user wants all values they just leave in the default values above and now you give they added flexibilty of having a range of values. PLUS the record evaluation is done on server side making it very fast.

Hope this helps
Jim

PS: you can do a similar thing with strings too or use wildcards
 
The way it is set up is to include any records with the numeric value less than the parameter input; if the user inputs a 2, then it will only select records where that field contains a number between 0 and 2.

I see what you're getting at with that, and we actually considered it...but we have a unique setup in that the reports are housed in a proprietary Lotus-based DB software. The user creates a report request, and the request is processed on the server when they replicate and emailed to them in .pdf format; the difference between processing time is miniscule, so we decided to use fewer parameters to avoid all that many more errors...

Anyway, here's how we finally got it to work:

(IF {?Minimum Class} in [&quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;]
then
{Equipment.Class}<= {?Minimum Class}
else
{Equipment.Class} <= &quot;5&quot;)

Why did it fix the Null problem? I believe by specifying specific numbers in an array instead of using a less than (<=) qualifier, it had an easier time ruling Null as not being &quot;true&quot;

Thanks for all your input!!
 
A null value would kill the whole formula. so in effect it ignored that record
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top