I am trying to create and distribute a report with Crystal Reorts 7.0 Pro. The user needs to be able to enter a date range.
In very simple tests, I can get this to work simply by adding a date range parameter and some code to the record selection formula. However, on the actual report I need to use a UNION and some subqueries, and it seems too complex to work with the record selection formula.
Here is the working SELECT statement with the dates hard-coded in (I apologize for the length). The ones I want the user to change are the DOCDATE fields:
SELECT PM00200.VENDNAME, PM20000.VCHRNMBR, PM20000.VENDORID, PM20000.DOCTYPE, PM20000.DOCDATE, PM20000.DOCNUMBR, PM20000.DOCAMNT, PM20000.TRXSORCE
FROM
CDI.dbo.PM20000 PM20000, CDI.dbo.PM00200 PM00200
WHERE
(SELECT COUNT(B.DOCNUMBR) FROM CDI.dbo.PM20000 B WHERE B.DOCDATE = PM20000.DOCDATE AND B.DOCAMNT = PM20000.DOCAMNT AND B.DOCNUMBR = PM20000.DOCNUMBR AND B.DOCTYPE = 1 AND B.VOIDED = 0) > 1
AND PM20000.VENDORID = PM00200.VENDORID
AND PM20000.DOCDATE >= '05/01/2000'
AND PM20000.DOCDATE <= '11/09/2000'
AND PM20000.VOIDED = 0
AND (PM20000.DOCTYPE = 1 OR PM20000.DOCTYPE = 5)
UNION
SELECT
PM00200.VENDNAME, PM30200.VCHRNMBR, PM30200.VENDORID, PM30200.DOCTYPE, PM30200.DOCDATE, PM30200.DOCNUMBR, PM30200.DOCAMNT, PM30200.TRXSORCE
FROM
CDI.dbo.PM30200 PM30200, CDI.dbo.PM00200 PM00200
WHERE
(SELECT COUNT(B.DOCNUMBR) FROM CDI.dbo.PM30200 B WHERE B.DOCDATE = PM30200.DOCDATE AND B.DOCAMNT = PM30200.DOCAMNT AND B.DOCNUMBR = PM30200.DOCNUMBR AND B.DOCTYPE = 1 AND B.VOIDED = 0) > 1
AND PM30200.VENDORID = PM00200.VENDORID
AND PM30200.DOCDATE >= '05/01/2000'
AND PM30200.DOCDATE <= '11/09/2000'
AND PM30200.VOIDED = 0
AND (PM30200.DOCTYPE = 1 OR PM30200.DOCTYPE = 5)
I have tried before to use the syntax "DOCDATE >= {?DateRange}" where DateRange is a parameter, but this does not work.
Is there any other way I can try to get parameters into the SELECT statement other than through the record selection formula? Thank-you for any help...I've spent days trying to get this to work!
In very simple tests, I can get this to work simply by adding a date range parameter and some code to the record selection formula. However, on the actual report I need to use a UNION and some subqueries, and it seems too complex to work with the record selection formula.
Here is the working SELECT statement with the dates hard-coded in (I apologize for the length). The ones I want the user to change are the DOCDATE fields:
SELECT PM00200.VENDNAME, PM20000.VCHRNMBR, PM20000.VENDORID, PM20000.DOCTYPE, PM20000.DOCDATE, PM20000.DOCNUMBR, PM20000.DOCAMNT, PM20000.TRXSORCE
FROM
CDI.dbo.PM20000 PM20000, CDI.dbo.PM00200 PM00200
WHERE
(SELECT COUNT(B.DOCNUMBR) FROM CDI.dbo.PM20000 B WHERE B.DOCDATE = PM20000.DOCDATE AND B.DOCAMNT = PM20000.DOCAMNT AND B.DOCNUMBR = PM20000.DOCNUMBR AND B.DOCTYPE = 1 AND B.VOIDED = 0) > 1
AND PM20000.VENDORID = PM00200.VENDORID
AND PM20000.DOCDATE >= '05/01/2000'
AND PM20000.DOCDATE <= '11/09/2000'
AND PM20000.VOIDED = 0
AND (PM20000.DOCTYPE = 1 OR PM20000.DOCTYPE = 5)
UNION
SELECT
PM00200.VENDNAME, PM30200.VCHRNMBR, PM30200.VENDORID, PM30200.DOCTYPE, PM30200.DOCDATE, PM30200.DOCNUMBR, PM30200.DOCAMNT, PM30200.TRXSORCE
FROM
CDI.dbo.PM30200 PM30200, CDI.dbo.PM00200 PM00200
WHERE
(SELECT COUNT(B.DOCNUMBR) FROM CDI.dbo.PM30200 B WHERE B.DOCDATE = PM30200.DOCDATE AND B.DOCAMNT = PM30200.DOCAMNT AND B.DOCNUMBR = PM30200.DOCNUMBR AND B.DOCTYPE = 1 AND B.VOIDED = 0) > 1
AND PM30200.VENDORID = PM00200.VENDORID
AND PM30200.DOCDATE >= '05/01/2000'
AND PM30200.DOCDATE <= '11/09/2000'
AND PM30200.VOIDED = 0
AND (PM30200.DOCTYPE = 1 OR PM30200.DOCTYPE = 5)
I have tried before to use the syntax "DOCDATE >= {?DateRange}" where DateRange is a parameter, but this does not work.
Is there any other way I can try to get parameters into the SELECT statement other than through the record selection formula? Thank-you for any help...I've spent days trying to get this to work!