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

Select All or {?Parameter} 2

Status
Not open for further replies.

infomania

Programmer
Oct 27, 2002
148
0
0
I want to create a formula where all records are selected in the event a numeric parameter (or any parameters) is not given.

I can do this for a string fields as below:
If {?Item Number}="" then {Command.itemNumber} like "*" else
{Command.itemNumber} like "*"+{?Item Number}+"*"

However, I am stumpted as to how to do this with a numeric field where the parameter does not allow for a null.


 
I usually use 0 as the default and then test for it, mostly because id #'s usually start with 1. You can use any "never gonna happen" number to test against.

If {?Item Number}= 0 then true
else if {?Item Number} <> 0 then
{Command.itemNumber} = {?Item Number}

Don't forget the else if syntax to make certain the parameter is sent to the DB.

Lisa
 
Lisa

Thank you. I tried this and it works for a single value. When I try this for a parameter with multiple values, I get an error that says this array must be scripted. Can you tell me how to do this properly? Unfortunately, 0 is a valid selection for me.

If {?Buyer Number}= -1 then true
else if {?Buyer Number} >= 0 then
{Command.buyerNumber} = {?Buyer Number}

 
You can't use >= with an array. This should work:

If {?Buyer Number}= -1 then true
else if not ({?Buyer Number} = -1) then
{Command.buyerNumber} = {?Buyer Number}

Lisa
 
That did it! Thank you for your quick response.
 
infomania and lyanch,

Bless you, infomania, for a well-worded subject line and question so I could find this post, and you, lyanch, for a concise answer! I had been working on a similar problem for 2 days and this answer fixed it perfectly!

Kristen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top