Saintor wrote:
This is for A97 in runtime or MDE mode.
My intent was to define a temporary query using the recordsetclone
property / filter / orderby. The controlsource of my chart would be
based on a grouped query based on this temporary query.
Is this the best way or is there another one more efficient?
Is it possible in a runtime environment to change the format of an
axis (by Week ---> by Month) or the chart controlsource on report
opening?
Easiest option would be to have two versions of the graph and display the
appropriate one.
You can pretty much manipulate anything via the Graph object in code... if
you have to.
Changing the axis from Week to Month really means changing the chart's
source data and then changing the axis label.
eg. to change X axis label
Sample call: SetChartXTitle Me![MyGraph], "Monthly"
Function SetChartXTitle(ByRef pGraphObject As Object, pChartPeriod As
String)
DoCmd.Hourglass True
Dim MyGraph As Object
Set MyGraph = pGraphObject.Object.Application
On Error Resume Next
If pChartPeriod = "Monthly" Then
'MyGraph.Chart.Axes(1, 1).TickLabels.Orientation =
xlTickLabelOrientationHorizontal
MyGraph.Chart.Axes(1, 1).HasTitle = True
MyGraph.Chart.Axes(1, 1).AxisTitle.Text = "Month"
Else
'MyGraph.Chart.Axes(1, 1).TickLabels.Orientation =
xlTickLabelOrientationUpward
MyGraph.Chart.Axes(1, 1).HasTitle = True
MyGraph.Chart.Axes(1, 1).AxisTitle.Text = "Week Commencing"
End If
MyGraph.Update
Set MyGraph = Nothing
DoCmd.Hourglass False
End Function
Sample code to reset the source data contained in the graph object (only
needed if you want to manually change the Graph's datasheet)
'Clear datasheet
MyGraph.Datasheet.Cells.ClearContents
'If no chart data then quit
If rs.RecordCount = 0 Then Exit Function
FieldCount = rs.Fields.Count
If FieldCount < 2 Then Exit Function
'Add data
row = 2
'rs.MoveFirst
Do Until rs.EOF
For col = 1 To FieldCount
If IsNull(rs.Fields(col - 1)) Then
MyGraph.Datasheet.Cells(row, col).ClearContents
Else
MyData = rs.Fields(col - 1)
MyGraph.Datasheet.Cells(row, col) = MyData
End If
Next
rs.MoveNext
row = row + 1
Loop
--
regards,
Br@dley