K
Kahuna
Hi Folks bee struggling with this one for a while. I have a chart on a
report for which I need to set the rowsource. I do the same on a form for
the same chart with total success, but this fails on the report. I have
listed the abridged code below, I get an error (2455) saying that
'Expression has Invalid Reference' or Rowsource is not applicable to the
Graph1 chart, or else the rowsource is simply not populated and the default
chart data is shown. Any comment welcome - cheers
================================================================
Private Sub Report_Open(Cancel As Integer)
DoCmd.Maximize
' Comments :
' Parameters :
' Created : 26-04-05 09:29:55 irjc
' Modified :
'
' --------------------------------------------------------
On Error GoTo Sub_ERR_Report_Open
'================================================
'Set recordsource to the sql for the particular scenario
Dim dbCurr As Database
Dim strRecSource1 As String ' Rowsource for each Graph
' in form that uses
Scenario
Dim varScenario As Variant ' The Scenario Number current
Set dbCurr = CurrentDb()
varScenario = DLookup("[ss_selected_scenario]", "system_settings")
Select Case varScenario 'Choose the correct recordsource for the
Current Scenario
Case 1 '====================
'SQL For Scenario 1 all Graphs
strRecSource1 = "SELECT analysis_codes.ad_description AS
[Analysis Code], Sum(budget_schedules.bs_time)" _
& " AS [Man Hours] FROM (qryFabricCondition
LEFT JOIN analysis_codes" _
& " ON qryFabricCondition.ad_analysis_code =
analysis_codes.ad_analysis_code)" _
& " LEFT JOIN budget_schedules ON
qryFabricCondition.fc_id = budget_schedules.fc_fabric_key" _
& " GROUP BY analysis_codes.ad_description,
qryFabricCondition.ad_analysis_code,
qryFabricCondition.fc_program_year" _
& " HAVING
(((qryFabricCondition.fc_program_year)=1)) ORDER BY
qryFabricCondition.ad_analysis_code:"
Me.Label0.Caption = "Scenario 1"
'MsgBox "Case 1 Selected"
Case 2 '====================
Case 3 '==================== 'etc.
End Select
Me!Graph1.RowSource = strRecSource1
Me!Graph1.Requery
Exit Sub
Sub_ERR_Report_Open:
MsgBox "Error number " & Err.Number & ": " & Err.description
End Sub
============================================================================
report for which I need to set the rowsource. I do the same on a form for
the same chart with total success, but this fails on the report. I have
listed the abridged code below, I get an error (2455) saying that
'Expression has Invalid Reference' or Rowsource is not applicable to the
Graph1 chart, or else the rowsource is simply not populated and the default
chart data is shown. Any comment welcome - cheers
================================================================
Private Sub Report_Open(Cancel As Integer)
DoCmd.Maximize
' Comments :
' Parameters :
' Created : 26-04-05 09:29:55 irjc
' Modified :
'
' --------------------------------------------------------
On Error GoTo Sub_ERR_Report_Open
'================================================
'Set recordsource to the sql for the particular scenario
Dim dbCurr As Database
Dim strRecSource1 As String ' Rowsource for each Graph
' in form that uses
Scenario
Dim varScenario As Variant ' The Scenario Number current
Set dbCurr = CurrentDb()
varScenario = DLookup("[ss_selected_scenario]", "system_settings")
Select Case varScenario 'Choose the correct recordsource for the
Current Scenario
Case 1 '====================
'SQL For Scenario 1 all Graphs
strRecSource1 = "SELECT analysis_codes.ad_description AS
[Analysis Code], Sum(budget_schedules.bs_time)" _
& " AS [Man Hours] FROM (qryFabricCondition
LEFT JOIN analysis_codes" _
& " ON qryFabricCondition.ad_analysis_code =
analysis_codes.ad_analysis_code)" _
& " LEFT JOIN budget_schedules ON
qryFabricCondition.fc_id = budget_schedules.fc_fabric_key" _
& " GROUP BY analysis_codes.ad_description,
qryFabricCondition.ad_analysis_code,
qryFabricCondition.fc_program_year" _
& " HAVING
(((qryFabricCondition.fc_program_year)=1)) ORDER BY
qryFabricCondition.ad_analysis_code:"
Me.Label0.Caption = "Scenario 1"
'MsgBox "Case 1 Selected"
Case 2 '====================
Case 3 '==================== 'etc.
End Select
Me!Graph1.RowSource = strRecSource1
Me!Graph1.Requery
Exit Sub
Sub_ERR_Report_Open:
MsgBox "Error number " & Err.Number & ": " & Err.description
End Sub
============================================================================