I'll bet that your parameter is a date type, rather than a datetime. Sometimes Crystal won't pass the SQL through based on that alone.
You'll get MUCH faster performance by just creating formulas to change the parameters into datetimes and referencing those in the record selection.
Do it one step at a time, checking the Database->Show SQL Query, so that you assure that every section passes, and don't reference any formulas that use a variable, this breaks the pass through.
Obviously a Stored Procedure will be faster, but a 2 million row return is what's punishing you.
Here's an example of how I'd try to address this:
I'll assume that the codes pass fine, we'll fix the dates:
Formula FromDate
datetime(year({?From Date}),month({?From Date}),day({?From Date}),0,0,0)
Formula ToDate
datetime(year({?To Date}),month({?To Date}),day({?To Date}),23,59,59)
IF {?Reference Code} <> "" AND {?Account Code} <> "" THEN
(
{mm_creative_services_inventory_vw.reference_code} = {?Reference Code}
)
AND
(
{mm_creative_services_inventory_vw.account_code} = {?Account Code}
)
AND
(
({mm_creative_services_inventory_vw.apply_date} = {?From Date} OR {mm_creative_services_inventory_vw.apply_date} >= {@FromDate})
)
AND
(
({mm_creative_services_inventory_vw.apply_date} = {?To Date} OR {mm_creative_services_inventory_vw.apply_date} <= {@ToDate})
)
Note the seemingly pointless parens, but I have examples of how CR won't pass the SQL without having this separation in place...
It's very persnickety about passing through SQL, but once you get a feel for how CR creates pass through, you'll be fine.
Hope that this resolves for you.
-k
kai@informeddatadecisions.com