PeteCresswell <x@y.z.Invalid> wrote:
On Thu, 05 May 2005 15:31:17 -0400, PeteCresswell <x@y.z.Invalid>
wrote:
but sometimes the cell assignments "stick" and sometimes they
don't.
Now it seems tb 100% replicable: if I put a break at line 3842, wait
for it to break, remove the break, then hit F5 to continue - the
.DataSheet.Cells() get loaded and I can see it happen on the form.
Without the break/single stepping they don't seem to get loaded.
Same thing if I single-step the code - but then one can see the data
points being added one-by-one.
Seems like I've been here before with some other object, but can't
recall what the problem was.
Here's my SetDatasheet function in full... hope you can make sense of
it.
Function SetDatasheet(pGraphObject As Object, pChartID As Long,
pExtractData As Boolean)
On Error Resume Next
SetCurrentChart pChartID 'set global user-defined variable to hold
current chart's properties
Dim MySeries As GraphSeries, MyChart As GraphChart, myDB As Database,
rsSeries As DAO.Recordset
Dim MyGraph As Object, MyData As String, SeriesTitle As String,
myChartType As String
Dim rs As DAO.Recordset
Dim row As Long, col As Long, FieldCount As Long
Dim Mseries As Boolean, Qseries As Boolean, Sseries As Boolean,
Tseries As Boolean
Dim FindSeries As String
Set myDB = CurrentDb()
Set rs = myDB.OpenRecordset("qryGraph", DB_OPEN_SNAPSHOT)
Set MyGraph = pGraphObject.Object.Application
Set rsSeries = myDB.OpenRecordset("qrySeriesList", DB_OPEN_SNAPSHOT)
If pExtractData Then
'Clear datasheet
'MyGraph.Datasheet.Cells.Delete
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 series names
row = 1
For col = 2 To FieldCount 'skip first date field
FindSeries = "[SeriesID] = " & rs.Fields(col - 1).Name
rsSeries.FindFirst FindSeries
If Not rsSeries.NoMatch Then
SeriesTitle = rsSeries![SeriesTitle]
MyGraph.Datasheet.Cells(row, col) = SeriesTitle
'MyGraph.DataSheet.Cells(row, col) = rs.Fields(col - 1).Name
'substitute series name as ID used now for field name
End If
Next
Set rsSeries = Nothing
'Add data
row = 2
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
End If
'Set series plot type
Dim PrimarySeries As Boolean, SecondarySeries As Boolean
Dim Series As DAO.Recordset, S As Long
Set Series = CurrentDb.OpenRecordset("qrySeries", DB_OPEN_SNAPSHOT)
S = 0
Sseries = False
Mseries = False
Qseries = False
Tseries = False
Series.MoveFirst
On Error Resume Next
PrimarySeries = False
SecondarySeries = False
Do Until Series.EOF
S = S + 1
Select Case Series![SeriesType]
Case "Mean": Mseries = True
Case "Questionnaire": Qseries = True
Case "Sales": Sseries = True
Case "Tarps": Tseries = True
End Select
If Series![PlotOnY2] Then
SecondarySeries = True
'Have to do following check else would fail for some reason
If MyGraph.Chart.SeriesCollection(S).AxisGroup <> xlSecondary Then
MyGraph.Chart.SeriesCollection(S).AxisGroup = xlSecondary
Else
PrimarySeries = True
If MyGraph.Chart.SeriesCollection(S).AxisGroup <> xlPrimary Then
MyGraph.Chart.SeriesCollection(S).AxisGroup = xlPrimary
End If
myChartType = Series![SeriesPlotType]
If myChartType <> "None" Then
MyGraph.Chart.SeriesCollection(S).ChartType = GetChartType(myChartType)
Series.MoveNext
Loop
MyGraph.Chart.HasTitle = True
MyGraph.Chart.ChartTitle.Text = GV_CURRENT_CHART.ChartTitle
'set axis titles
If PrimarySeries Then
If GV_CURRENT_CHART.ChartAutoY1Title Then
MyGraph.Chart.Axes(2, 1).HasTitle = True
If Qseries Then
If Mseries Then
MyGraph.Chart.Axes(2, 1).AxisTitle.Text = "%/Mean"
Else
MyGraph.Chart.Axes(2, 1).AxisTitle.Text = "%"
End If
Else
If Mseries Then
MyGraph.Chart.Axes(2, 1).AxisTitle.Text = "Mean"
Else
MyGraph.Chart.Axes(2, 1).AxisTitle.Text = ""
End If
End If
End If
If GV_CURRENT_CHART.ChartAutoY2Title Then
MyGraph.Chart.Axes(2, 1).AxisTitle.Font.Bold = False
If SecondarySeries Then
MyGraph.Chart.Axes(2, 2).HasTitle = True
'MyGraph.Chart.Axes(2, 2).AxisTitle.Text = "Tarp"
If Tseries Then
If Sseries Then
MyGraph.Chart.Axes(2, 2).AxisTitle.Text = "Tarp/Sales"
Else
MyGraph.Chart.Axes(2, 2).AxisTitle.Text = "Tarp"
End If
Else
If Sseries Then
MyGraph.Chart.Axes(2, 2).AxisTitle.Text = "Sales"
Else
MyGraph.Chart.Axes(2, 2).AxisTitle.Text = ""
End If
End If
MyGraph.Chart.Axes(2, 2).AxisTitle.Font.Bold = False
End If
End If
Else
If GV_CURRENT_CHART.ChartAutoY2Title Then
If SecondarySeries Then
MyGraph.Chart.Axes(2, 2).HasTitle = True
'MyGraph.Chart.Axes(2, 1).AxisTitle.Text = "Tarp"
If Tseries Then
If Sseries Then
MyGraph.Chart.Axes(2, 2).AxisTitle.Text = "Tarp/Sales"
Else
MyGraph.Chart.Axes(2, 2).AxisTitle.Text = "Tarp"
End If
Else
If Sseries Then
MyGraph.Chart.Axes(2, 2).AxisTitle.Text = "Sales"
Else
MyGraph.Chart.Axes(2, 2).AxisTitle.Text = ""
End If
End If
MyGraph.Chart.Axes(2, 1).AxisTitle.Font.Bold = False
End If
End If
End If
If GV_CURRENT_CHART.ChartAutoXTitle Then
If GV_CURRENT_CHART.ChartPeriod = "Monthly" Then
MyGraph.Chart.Axes(1, 1).HasTitle = True
MyGraph.Chart.Axes(1, 1).AxisTitle.Text = "Month"
Else
MyGraph.Chart.Axes(1, 1).HasTitle = True
MyGraph.Chart.Axes(1, 1).AxisTitle.Text = "Week Commencing"
End If
End If
MyGraph.Update
SetDatasheet_exit:
Set MyGraph = Nothing
Set Series = Nothing
Set rs = Nothing
Exit Function
SetDatasheet_err:
Resume SetDatasheet_exit
End Function
--
regards,
Bradley
A Christian Response
http://www.pastornet.net.au/response