I am having problems with the following code:
I get a runtime error 438. object does not support this property or method.
When i type the line in, the code automatically capitalises the line. So something is recognised. If i change the line to With .SeriesCollection.Add this done the same.
Do i need to reference anything else? The .count and .delete methods are working so why not the .newseries
Has anyone got any light to shed on this please?
Thanks
TimW
Code:
Private Sub Form_Load()
Dim graphOb As Object
Dim rsCount, i, j As Integer
Dim mySQL As String
Dim db As Database
Dim rs As DAO.Recordset
Dim myData, arrA, arrB, arrC, arrD As Variant
Dim ns As Object
Set db = CurrentDb
' ************************************* _
* Bring in information from Query * _
*************************************
mySQL = "SELECT * " & _
"FROM qryDowntime4Graph " & _
"WHERE ([ShiftLogRef] = " & Forms!frmShiftLog.Reference & ")" & _
" ORDER BY [DowntimeStartDate];"
'Debug.Print mySQL
' **************************************** _
* Create recordset and put into array * _
* ~ myData ~ * _
****************************************
Set rs = db.OpenRecordset(mySQL, dbOpenDynaset)
With rs
rsCount = .RecordCount
If .RecordCount > 0 Then
.MoveFirst
ReDim myData(rsCount, 8) ' 8 is the number of columns in qryDowntime4Graph
ReDim arrA(rsCount)
ReDim arrB(rsCount)
ReDim arrC(rsCount)
ReDim arrD(rsCount)
myData = .GetRows(rsCount)
Else:
MsgBox "No Data to graph", vbCritical + vbOKOnly, "No data"
Exit Sub
End If
End With
' Finished with rs
rs.Close
Set rs = Nothing
For i = 0 To rsCount - 1
arrA(i) = myData(2, i) ' Start DT information
arrB(i) = myData(4, i) ' Cause
arrC(i) = myData(5, i) ' Duration
arrD(i) = myData(1, i) ' Stopped
Next
Set graphOb = Me.chartDTGantt
' Me.graphSample.RowSource = "tblData"
' *** define graph ***
With graphOb
.ChartType = xlBarStacked
.HasTitle = True
.ChartTitle.Text = "Downtime"
With .Axes(xlCategory)
.HasTitle = True
.AxisTitle.Caption = "Downtime reason"
End With
With .Axes(xlValue)
.HasTitle = True
.AxisTitle.Caption = "Date - shift"
.MinimumScale = #9/7/2009#
.MaximumScale = #9/9/2009#
.TickLabels.NumberFormat = "h:mm AM/PM"
Debug.Print graphOb.SeriesCollection.Count
End With
' *** Delete series collection before adding new ***
Do Until .SeriesCollection.Count = 0
.SeriesCollection(1).Delete
Loop
' ***************************************************** _
* Create two series collections * _
* 1, For start time & * _
* 2, For duration * _
*****************************************************
With .SeriesCollection.NewSeries ' [COLOR=red]code stops here[/COLOR]
.Values = arrA
.XValues = arrB
End With
With .SeriesCollection.NewSeries
.Values = arrC
.Name = "Downtime"
End With
End With
End Sub
When i type the line in, the code automatically capitalises the line. So something is recognised. If i change the line to With .SeriesCollection.Add this done the same.
Do i need to reference anything else? The .count and .delete methods are working so why not the .newseries
Has anyone got any light to shed on this please?
Thanks
TimW