bluevelvet
Programmer
Can anyone help. I have the following if statement:
{@DateOriginal} = {?DateOriginal} and
(if{?StockNumber}="" then {IPPOITM.STOCK_NUMBER}like"*" and {IPPOITM.VENDOR_NUMBER}like{?Vendor}
else if {?StockNumber}<>""then{IPPOITM.STOCK_NUMBER}like{?StockNumber}and {IPPOITM.VENDOR_NUMBER}like {?Vendor}
else if {?Vendor}="" then {IPPOITM.VENDOR_NUMBER}like "*" and {IPPOITM.STOCK_NUMBER}like {?StockNumber}
else if {?Vendor}<>"" then {IPPOITM.VENDOR_NUMBER}like{?Vendor} and {IPPOITM.STOCK_NUMBER}like {?StockNumber})
The idea is that you should be able to pass a date parameter and then choose whether or not to provide stock numbers and vendors. If you leave the stock number or vendor parameter empty it should return all within the constraints of the other parameter values passed.
These are the results I am getting:
Give a date range - no records returned
Give date and vendor - correct record set returned
Give date and stock number - no records returned
Give date,vendor and stock number - correct date and vendor but returns all stock numbers
I can't figure out what's wrong, the if statement looks fine to me. I am running Crystal version 9.
Any help would be very much appreciated.
{@DateOriginal} = {?DateOriginal} and
(if{?StockNumber}="" then {IPPOITM.STOCK_NUMBER}like"*" and {IPPOITM.VENDOR_NUMBER}like{?Vendor}
else if {?StockNumber}<>""then{IPPOITM.STOCK_NUMBER}like{?StockNumber}and {IPPOITM.VENDOR_NUMBER}like {?Vendor}
else if {?Vendor}="" then {IPPOITM.VENDOR_NUMBER}like "*" and {IPPOITM.STOCK_NUMBER}like {?StockNumber}
else if {?Vendor}<>"" then {IPPOITM.VENDOR_NUMBER}like{?Vendor} and {IPPOITM.STOCK_NUMBER}like {?StockNumber})
The idea is that you should be able to pass a date parameter and then choose whether or not to provide stock numbers and vendors. If you leave the stock number or vendor parameter empty it should return all within the constraints of the other parameter values passed.
These are the results I am getting:
Give a date range - no records returned
Give date and vendor - correct record set returned
Give date and stock number - no records returned
Give date,vendor and stock number - correct date and vendor but returns all stock numbers
I can't figure out what's wrong, the if statement looks fine to me. I am running Crystal version 9.
Any help would be very much appreciated.