From rwel, 2/3/2005, 0848 EST
I have coded the following "work around".
The inability to set the rowsource for a graph stems from the fact that MSAccess 2000 (and likly other versions ?) only supports setting the rowsource in "acDesign" mode.
The workaround is to:
1. silently (echo off) put the report into acDesign mode
2. make the rowsource assignment(s)
3. save the report
4. turn echo back on
5. continue all other processing which eventually leads to
opening the report in acPrintPriview
A very ugly solution with the following limitations:
1. cannont be used in an .mde database since the report cannot be open in acDesign mode in an .mde databas
2. Must give users design privileges sionce they are , via code, opening the report in acDesign mode.
The key to this understanding was contained in MSKnowledgebase article 209993 but was subtly understated
so that it required very careful reading to get the salient point, namely that the rowsource can be set unless you are in acDesign mode.
Hope MS fixes this limitation in future releases of ACCESS.
rwel
BELOW is rwel's code which sets rowsource for 8 graphs:
'------------------------------------------------------------
' Mac209993
'
'------------------------------------------------------------
Function Mac209993()
On Error GoTo Mac209993_Err
DoCmd.Echo False, ""
DoCmd.OpenReport "rptLaraEnergies", acDesign, "", ""
Reports!rptLaraEnergies!GphRG1.RowSource = "SELECT SR_LOG_NUM, [RG1ENERGY]*1000000 AS Scaled_RG1ENERGY FROM tblMasterDriver" & CurrentUser() & "; "
Reports!rptLaraEnergies!GphRG2.RowSource = "SELECT SR_LOG_NUM, IIf(PSL_PCM_ID=""812"",""41"",IIf(PSL_PCM_ID=""811"",""61"",IIf(PSL_PCM_ID=""813"",""84"",""""))) AS LSL, " & _
" IIf(PSL_PCM_ID=""812"",""43"",IIf(PSL_PCM_ID=""811"",""63"",IIf(PSL_PCM_ID=""813"",""86"",""""))) AS USL, [RG2ENERGY]*1000000 AS RE2, [UCL]*1000000 AS UpCL, [LCL]*1000000 AS LowCL, [Mean]*1000000 AS Average " & _
" FROM tblRE2StatsUCLLCLFullUnion" & CurrentUser() & "; "
Reports!rptLaraEnergies!GphLARA.RowSource = " SELECT SR_LOG_NUM, ENERGY AS ['LARA']FROM tblMasterDriver" & CurrentUser() & "; "
Reports!rptLaraEnergies!GphDriver.RowSource = " SELECT SR_LOG_NUM, DOENERGY, Mean, UCL, LCL FROM tblGraph64StatsFullUnion" & CurrentUser() & "; "
Reports!rptLaraEnergies!GphLARAGain.RowSource = " SELECT SR_LOG_NUM, [ENERGY]/[RG2ENERGY] AS ['LARA Gain'] FROM tblMasterDriver" & CurrentUser() & "; "
Reports!rptLaraEnergies!GphDriverGain.RowSource = " SELECT SR_LOG_NUM, [DOENERGY]/[ENERGY] AS ['Driver Gain']FROM tblMasterDriver" & CurrentUser() & "; "
Reports!rptLaraEnergies!GphFilmEllip.RowSource = " SELECT RG1SR_DATE, FilmEllipticity, Limit FROM tblOMEGA_ELLIPTICITY_Film" & CurrentUser() & ";"
Reports!rptLaraEnergies!GphCCDEllip.RowSource = " SELECT RG1SR_DATE, CCD_Ellipticity, Limit FROM tblOMEGA_OMA_ELLIP_CCD" & CurrentUser() & ";"
DoCmd.RunCommand acCmdSave
DoCmd.Echo True, ""
Mac209993_Exit:
Exit Function
Mac209993_Err:
MsgBox Error$
Resume Mac209993_Exit
End Function