M
Mona-ABE
Hi,
When I use an Access query (SQL copied below) as the recordsource for a
report with specific dates, it works perfectly. I'd like to use the same SQL
in VBA in the report's OnOpen event to set the RecordSource property and use
variables in place of the dates 5/1/2006, 6/1/2006 and 7/1/2006 respectively.
I've been able to use the SELECT, FROM AND ORDER BY portions of the SQL with
no problem, but am receiving errors on the portions with the nz(dsum(....)
statements. I'm sure it's the syntax, and I need help!!
Thanks in advance for the advice!
Mona
-------------------------------------
SELECT tblPrjTrkConsultantLeaderList.projEmployeeID, [projFirstName] & " " &
[projLastName] AS Resource,
nz(DSum("[tblPrjTrkForecastedDays]![ProjForecastDays]","tblPrjTrkForecastedDays","[tblPrjTrkForecastedDays]![ProjEmplID]="
& [projEmployeeID] & " And
[tblPrjTrkForecastedDays]![ProjForecastMonth]=#5/1/2006#"),0) AS
[MO1-1Forecast],
nz(DSum("[tblPrjTrkActualDays]![ProjActualDays]","tblPrjTrkActualDays","[tblPrjTrkActualDays]![ProjEmplID]="
& [projEmployeeID] & " And
[tblPrjTrkActualDays]![ProjActualMonth]=#5/1/2006#"),0) AS [MO1-2Actual],
[MO1-1Forecast]-[MO1-2Actual] AS [MO1-3Difference],
nz(DSum("[tblPrjTrkForecastedDays]![ProjForecastDays]","tblPrjTrkForecastedDays","[tblPrjTrkForecastedDays]![ProjEmplID]="
& [projEmployeeID] & " And
[tblPrjTrkForecastedDays]![ProjForecastMonth]=#6/1/2006#"),0) AS
[MO2-1Forecast],
nz(DSum("[tblPrjTrkActualDays]![ProjActualDays]","tblPrjTrkActualDays","[tblPrjTrkActualDays]![ProjEmplID]="
& [projEmployeeID] & " And
[tblPrjTrkActualDays]![ProjActualMonth]=#6/1/2006#"),0)
AS [MO2-2Actual], [MO2-1Forecast]-[MO2-2Actual] AS [MO2-3Difference],
nz(DSum("[tblPrjTrkForecastedDays]![ProjForecastDays]","tblPrjTrkForecastedDays","[tblPrjTrkForecastedDays]![ProjEmplID]="
& [projEmployeeID] & " And
[tblPrjTrkForecastedDays]![ProjForecastMonth]=#7/1/2006#"),0) AS
[MO3-1Forecast],
nz(DSum("[tblPrjTrkActualDays]![ProjActualDays]","tblPrjTrkActualDays","[tblPrjTrkActualDays]![ProjEmplID]="
& [projEmployeeID] & " And
[tblPrjTrkActualDays]![ProjActualMonth]=#7/1/2006#"),0) AS [MO3-2Actual],
[MO3-1Forecast]-[MO3-2Actual] AS [MO3-3Difference]
FROM tblPrjTrkConsultantLeaderList
ORDER BY [projFirstName] & " " & [projLastName];
When I use an Access query (SQL copied below) as the recordsource for a
report with specific dates, it works perfectly. I'd like to use the same SQL
in VBA in the report's OnOpen event to set the RecordSource property and use
variables in place of the dates 5/1/2006, 6/1/2006 and 7/1/2006 respectively.
I've been able to use the SELECT, FROM AND ORDER BY portions of the SQL with
no problem, but am receiving errors on the portions with the nz(dsum(....)
statements. I'm sure it's the syntax, and I need help!!
Thanks in advance for the advice!
Mona
-------------------------------------
SELECT tblPrjTrkConsultantLeaderList.projEmployeeID, [projFirstName] & " " &
[projLastName] AS Resource,
nz(DSum("[tblPrjTrkForecastedDays]![ProjForecastDays]","tblPrjTrkForecastedDays","[tblPrjTrkForecastedDays]![ProjEmplID]="
& [projEmployeeID] & " And
[tblPrjTrkForecastedDays]![ProjForecastMonth]=#5/1/2006#"),0) AS
[MO1-1Forecast],
nz(DSum("[tblPrjTrkActualDays]![ProjActualDays]","tblPrjTrkActualDays","[tblPrjTrkActualDays]![ProjEmplID]="
& [projEmployeeID] & " And
[tblPrjTrkActualDays]![ProjActualMonth]=#5/1/2006#"),0) AS [MO1-2Actual],
[MO1-1Forecast]-[MO1-2Actual] AS [MO1-3Difference],
nz(DSum("[tblPrjTrkForecastedDays]![ProjForecastDays]","tblPrjTrkForecastedDays","[tblPrjTrkForecastedDays]![ProjEmplID]="
& [projEmployeeID] & " And
[tblPrjTrkForecastedDays]![ProjForecastMonth]=#6/1/2006#"),0) AS
[MO2-1Forecast],
nz(DSum("[tblPrjTrkActualDays]![ProjActualDays]","tblPrjTrkActualDays","[tblPrjTrkActualDays]![ProjEmplID]="
& [projEmployeeID] & " And
[tblPrjTrkActualDays]![ProjActualMonth]=#6/1/2006#"),0)
AS [MO2-2Actual], [MO2-1Forecast]-[MO2-2Actual] AS [MO2-3Difference],
nz(DSum("[tblPrjTrkForecastedDays]![ProjForecastDays]","tblPrjTrkForecastedDays","[tblPrjTrkForecastedDays]![ProjEmplID]="
& [projEmployeeID] & " And
[tblPrjTrkForecastedDays]![ProjForecastMonth]=#7/1/2006#"),0) AS
[MO3-1Forecast],
nz(DSum("[tblPrjTrkActualDays]![ProjActualDays]","tblPrjTrkActualDays","[tblPrjTrkActualDays]![ProjEmplID]="
& [projEmployeeID] & " And
[tblPrjTrkActualDays]![ProjActualMonth]=#7/1/2006#"),0) AS [MO3-2Actual],
[MO3-1Forecast]-[MO3-2Actual] AS [MO3-3Difference]
FROM tblPrjTrkConsultantLeaderList
ORDER BY [projFirstName] & " " & [projLastName];