I have two derived fields which return strings containing the date three days prior to the current date and three days after the current date. they are strings in the format that the Selection criteria uses when it's in SQL.
I have linked the macros to Before the report opens, but I still get "Invalid Column name".
Is there any way to make this do what I want?
Here's the SQL text, my macro text follows:
SELECT
SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'H',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) , SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'H',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) , SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'B',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) , SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'B',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) , ( SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'H',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) ) - ( SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'H',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) ), ( SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'B',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) ) - ( SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'B',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) ), @DECODE(REPORTS.V_DEDUCTIONS.COMPANYCODE,'K89','WCC','QH6','ICC','T4D','WAL','578','CT','CNQ','DCC','8OY','PG','?') , REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWPAYDATE, REPORTS.V_EMPLOYEE.NAME
FROM
REPORTS.V_DEDUCTIONS, REPORTS.V_CHK_VW_DEDUCTION, REPORTS.V_EMPLOYEE
WHERE
(((REPORTS.V_EMPLOYEE.EMPLOYEETYPE <> 'C') AND
(REPORTS.V_EMPLOYEE.STATUS <> 'T') AND
(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWPAYDATE BETWEEN (threedaysagoDate) AND (threedaysafterDate))))
AND
(REPORTS.V_DEDUCTIONS.FILE# = REPORTS.V_EMPLOYEE.FILE# ) AND (REPORTS.V_CHK_VW_DEDUCTION.COMPANYCODE (+)= REPORTS.V_DEDUCTIONS.COMPANYCODE ) AND (REPORTS.V_CHK_VW_DEDUCTION.FILE# (+)= REPORTS.V_DEDUCTIONS.FILE# ) AND (REPORTS.V_CHK_VW_DEDUCTION.SOCIALINSURANCE# (+)= REPORTS.V_DEDUCTIONS.SOCIALINSURANCE# ) AND (REPORTS.V_CHK_VW_DEDUCTION.COMPANYCODE (+)= REPORTS.V_EMPLOYEE.COMPANYCODE ) AND (REPORTS.V_CHK_VW_DEDUCTION.FILE# (+)= REPORTS.V_EMPLOYEE.FILE# ) AND (REPORTS.V_CHK_VW_DEDUCTION.SOCIALINSURANCE# (+)= REPORTS.V_EMPLOYEE.SOCIALINSURANCE# )
GROUP BY
REPORTS.V_DEDUCTIONS.COMPANYCODE, REPORTS.V_DEDUCTIONS.FILE#, REPORTS.V_EMPLOYEE.NAME, REPORTS.V_EMPLOYEE.COMPANYCODE, REPORTS.V_EMPLOYEE.FILE#, REPORTS.V_EMPLOYEE.STATUS, REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWPAYDATE, REPORTS.V_DEDUCTIONS.SOCIALINSURANCE#, REPORTS.V_CHK_VW_DEDUCTION.COMPANYCODE, REPORTS.V_CHK_VW_DEDUCTION.FILE#, REPORTS.V_CHK_VW_DEDUCTION.SOCIALINSURANCE#, REPORTS.V_EMPLOYEE.SOCIALINSURANCE#, REPORTS.V_EMPLOYEE.EMPLOYEETYPE
HAVING
(( (((( SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'H',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) ) - ( SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'H',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) )) > 0) OR
((( SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'B',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) ) - ( SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'B',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) )) > 0))))
ORDER BY
REPORTS.V_EMPLOYEE.NAME
Here's the macro code for the date three days ago:
Sub threedaysagoDate()
Dim today as variant
Dim Daytodayval as variant
Dim Monthtoday as variant
Dim Yeartoday as variant
Dim threedaysagoDay as variant
Dim threedaysago as variant
today = Date$
Daytodayval=Val(Mid$(today,4,2))
Monthtoday=Left$(today, 2)
Yeartoday=Right$(today,4)
threedaysagoDay=(Daytodayval - 3)
threedaysagoDay = Ltrim$(str(threedaysagoDay))
threedaysago = str(Yeartoday + "-" + Monthtoday + "-" + threedaysagoDay)
DerivedField threedaysago
End Sub
Thank you for any and all help!
I have linked the macros to Before the report opens, but I still get "Invalid Column name".
Is there any way to make this do what I want?
Here's the SQL text, my macro text follows:
SELECT
SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'H',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) , SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'H',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) , SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'B',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) , SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'B',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) , ( SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'H',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) ) - ( SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'H',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) ), ( SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'B',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) ) - ( SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'B',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) ), @DECODE(REPORTS.V_DEDUCTIONS.COMPANYCODE,'K89','WCC','QH6','ICC','T4D','WAL','578','CT','CNQ','DCC','8OY','PG','?') , REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWPAYDATE, REPORTS.V_EMPLOYEE.NAME
FROM
REPORTS.V_DEDUCTIONS, REPORTS.V_CHK_VW_DEDUCTION, REPORTS.V_EMPLOYEE
WHERE
(((REPORTS.V_EMPLOYEE.EMPLOYEETYPE <> 'C') AND
(REPORTS.V_EMPLOYEE.STATUS <> 'T') AND
(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWPAYDATE BETWEEN (threedaysagoDate) AND (threedaysafterDate))))
AND
(REPORTS.V_DEDUCTIONS.FILE# = REPORTS.V_EMPLOYEE.FILE# ) AND (REPORTS.V_CHK_VW_DEDUCTION.COMPANYCODE (+)= REPORTS.V_DEDUCTIONS.COMPANYCODE ) AND (REPORTS.V_CHK_VW_DEDUCTION.FILE# (+)= REPORTS.V_DEDUCTIONS.FILE# ) AND (REPORTS.V_CHK_VW_DEDUCTION.SOCIALINSURANCE# (+)= REPORTS.V_DEDUCTIONS.SOCIALINSURANCE# ) AND (REPORTS.V_CHK_VW_DEDUCTION.COMPANYCODE (+)= REPORTS.V_EMPLOYEE.COMPANYCODE ) AND (REPORTS.V_CHK_VW_DEDUCTION.FILE# (+)= REPORTS.V_EMPLOYEE.FILE# ) AND (REPORTS.V_CHK_VW_DEDUCTION.SOCIALINSURANCE# (+)= REPORTS.V_EMPLOYEE.SOCIALINSURANCE# )
GROUP BY
REPORTS.V_DEDUCTIONS.COMPANYCODE, REPORTS.V_DEDUCTIONS.FILE#, REPORTS.V_EMPLOYEE.NAME, REPORTS.V_EMPLOYEE.COMPANYCODE, REPORTS.V_EMPLOYEE.FILE#, REPORTS.V_EMPLOYEE.STATUS, REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWPAYDATE, REPORTS.V_DEDUCTIONS.SOCIALINSURANCE#, REPORTS.V_CHK_VW_DEDUCTION.COMPANYCODE, REPORTS.V_CHK_VW_DEDUCTION.FILE#, REPORTS.V_CHK_VW_DEDUCTION.SOCIALINSURANCE#, REPORTS.V_EMPLOYEE.SOCIALINSURANCE#, REPORTS.V_EMPLOYEE.EMPLOYEETYPE
HAVING
(( (((( SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'H',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) ) - ( SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'H',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) )) > 0) OR
((( SUM(DISTINCT @DECODE(REPORTS.V_DEDUCTIONS.DEDUCTIONCODE,'B',REPORTS.V_DEDUCTIONS.DEDUCTIONAMOUNT,0) ) ) - ( SUM(DISTINCT @DECODE(REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDCODE,'B',REPORTS.V_CHK_VW_DEDUCTION.CHECKVIEWDEDAMT,0) ) )) > 0))))
ORDER BY
REPORTS.V_EMPLOYEE.NAME
Here's the macro code for the date three days ago:
Sub threedaysagoDate()
Dim today as variant
Dim Daytodayval as variant
Dim Monthtoday as variant
Dim Yeartoday as variant
Dim threedaysagoDay as variant
Dim threedaysago as variant
today = Date$
Daytodayval=Val(Mid$(today,4,2))
Monthtoday=Left$(today, 2)
Yeartoday=Right$(today,4)
threedaysagoDay=(Daytodayval - 3)
threedaysagoDay = Ltrim$(str(threedaysagoDay))
threedaysago = str(Yeartoday + "-" + Monthtoday + "-" + threedaysagoDay)
DerivedField threedaysago
End Sub
Thank you for any and all help!