i need to provide an option in the report so that I can pass a parameter to this for Order By. Right now it is very simple and following things I am willing to achieve..
1 - Add a new Parameter to this report called @OrderBy
2 - If the value of the @OrderBy is null or blank then use the Order By DaysLate DESC (means the current functionality will be as it is)
3 - If the value of @OrderBy is 1 then use Order By RugID ASC (means we will order the rugs by rugid in ascending order instead of days late descending order)
What I have achieved so far is:
Declare a parameter called "OrderBy" in report parameters and test these queries:
- SELECT RugID, Description, DesignCode, Size, Rate, Price, OrderNo, CONNo, DaysLate, CustomerID, ShippedTo, ShippingAddressIDFK, SizeForReport
- FROM ConDueRugsView
- WHERE (CustomerID = @OrderBy) OR
- (@OrderBy IS NULL)
- ORDER BY DaysLate DESC
and
- SELECT RugID, Description, DesignCode, Size, Rate, Price, OrderNo, CONNo, DaysLate, CustomerID, ShippedTo, ShippingAddressIDFK, SizeForReportFROM ConDueRugsViewWHERE (@OrderBy = 1)
- ORDER BY RugID ASC
It works good but how to use this in " if - else " statement?