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

IIF Function in Dataset

Status
Not open for further replies.

tb

Programmer
May 27, 2003
328
Hi all,
(Newbie)

I am trying to build my WHERE clause with the IIF function.
I have 4 parameters that include a "ALL" option and that is what I am trying to cater for.

Have done is successfully when there is only one parameter involved,
IIF (Parameters!Rep.Value = "0", " WHERE A.Region = '" & Parameters!Region.Value & "'" , " WHERE A.Region = '" & Parameters!Region.Value & "' AND A.SLPRSNID = '" & Parameters!Rep.Value & "'")

but now I have multiple conditions ... have tried the following ...
" WHERE (CustomerServiceRatesReport.Region = @Region) " &
IIF (Parameters!Rep.Value = "0", "" , " AND CustomerServiceRatesReport.SLPRSNID = '" & Parameters!Rep.Value & "'") &
IIF (Parameters!Depot.Value = "0", "" , " AND CustomerServiceRatesReport.OFFID = '" & Parameters!Depot.Value & "'") &
IIF (Parameters!ContractType.Value = "0", "" , " AND CustomerServiceRatesReport.AV_Contract_Type = '" & Parameters!ContractType.Value & "'") &
IIF (Parameters!CustomerNumber.Value = "0", "" , " AND CustomerServiceRatesReport.CUSTNMBR = '" & Parameters!CustomerNumber.Value & "'")

The above does not give me any errors, but neither does it give me any results on the report :) - no matter what my parameter selections are.

Any help / pointers or suggestions on how I can make this work or alternatives would be much appreciated.

Thnx,
tb

I was standing in the park, wondering why frisbees got bigger as they came closer... then it hit me!
 
If anybody is interested ...I found the solution to my problem ...

WHERE (CustomerServiceRatesReport.Region = @Region) AND
ISNULL(RTRIM(CustomerServiceRatesReport.SLPRSNID ),'') = COALESCE(@Rep,RTRIM(CustomerServiceRatesReport.SLPRSNID ),'')
AND
ISNULL(RTRIM(CustomerServiceRatesReport.OFFID),'') = COALESCE(@Depot,RTRIM(CustomerServiceRatesReport.OFFID ),'')
AND
ISNULL(RTRIM(CustomerServiceRatesReport.AV_Contract_Type),'') = COALESCE(@ContractType, RTRIM(CustomerServiceRatesReport.AV_Contract_Type),'')
AND
ISNULL(RTRIM(CustomerServiceRatesReport.CUSTNMBR),'') = COALESCE(@CustomerNumber, RTRIM(CustomerServiceRatesReport.CUSTNMBR),'')

I was standing in the park, wondering why frisbees got bigger as they came closer... then it hit me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top