hi,please help.when i try to plot chart from the mschart have this runtime error appear.Runtime error '3021'.
this is the current code:
Code:
Con.Open "driver={SQL Server};Server=ERP_server;Uid=sa;pwd=sa;database=SPC"
Set Rss = Nothing
Rss.Open " Select sum(sampleno/5)as subgroup,avg(data)as avgdata ,avg(sevenpoint)as seven, time,date from spcdata where date between '" & Format$(startdate, "yyyy-mm-dd") & "' and '" & Format$(enddate, "yyyy-mm-dd") & "' and partno ='" & partno & "'and dimension = '" & dimension & "' and machineno ='" & machineno & "'group by date,time", Con, adOpenKeyset ' Making Recordset
rs1.Open "SELECT PartNo, Dimension,Nominal, UCL, LCL From PartList WHERE PartNo = '" & partno & "' AND Dimension = '" & dimension & "' ", Con, adOpenKeyset ' Making Recordset
If Rss.RecordCount = 0 Then ' If no Record in Database, then Show an Error Msg and Exit the Sub
Else
ReDim ArrayChart(1 To Rss.RecordCount, 1 To 5) ' Array
For X = 1 To Rss.RecordCount
ArrayChart(X, 1) = Rss!avgdata
ArrayChart(X, 2) = rs1!ucl
ArrayChart(X, 3) = rs1!lcl
ArrayChart(X, 4) = (rs1!lcl + rs1!ucl) / 2
ArrayChart(X, 5) = Rss!seven
Rss.MoveNext
Next X
' 'Set manually the setting of the Scale of Axis
MSChart1.Plot.Axis(VtChAxisIdY).ValueScale.Auto = False
MSChart1.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = (rs1!ucl) + (0.2 * ((rs1!ucl) - (rs1!lcl)))
MSChart1.Plot.Axis(VtChAxisIdY).ValueScale.Minimum = (rs1!lcl) - (0.2 * ((rs1!ucl) - (rs1!lcl)))
'# Assigns array to the MSChart control #
MSChart1.ChartData = ArrayChart
MSChart1.SeriesType = VtChSeriesType2dLine
MSChart1.Refresh
End If
If Rss!seven < rs1!lcl Then error message higlight at this line
MSChart1.Plot.SeriesCollection(5).SeriesMarker.Show = False
Else
MSChart1.Plot.SeriesCollection(5).SeriesMarker.Show = True
End If
With MSChart1.Plot.SeriesCollection(1)
.SeriesMarker.Auto = False
.DataPoints.Item(-1).Marker.Visible = True
.DataPoints.Item(-1).Marker.Size = 65
.DataPoints.Item(-1).Marker.Style = VtMarkerStyleSquare
End With
With MSChart1.Plot.SeriesCollection(5)
.SeriesMarker.Auto = False
.DataPoints.Item(-1).Marker.Visible = True
.DataPoints.Item(-1).Marker.Size = 65
.DataPoints.Item(-1).Marker.Style = VtMarkerStyleSquare
End With
Set Rss = Nothing
Set rs1 = Nothing
End Sub
actually i'm try to hide the marker if the rss!seven is less than the rs1!lcl scale .i don't know is work for mschart from vb or not.please help thanks.
Last edited by gracehskuo; Jun 15th, 2008 at 09:53 PM.
hi,thanks reply.i still facing the same error message.please guide .
this is the current code:
Code:
If Not Rss.EOF And Rss.BOF Then
MsgBox "no record"
Else
If Rss!seven < rs1!lcl Then
MSChart1.Plot.SeriesCollection(5).SeriesMarker.Show = False
Else
MSChart1.Plot.SeriesCollection(5).SeriesMarker.Show = True
End If
End If
RobDog888:
hi,i try the method as you guide,but the error remain the same.
this is the current code:
Code:
If ((Rss.EOF = False) And (Rss.BOF = False)) Then
MsgBox "no record"
Else
If Rss!seven < rs1!lcl Then error highlight at this line
MSChart1.Plot.SeriesCollection(5).SeriesMarker.Show = False
Else
MSChart1.Plot.SeriesCollection(5).SeriesMarker.Show = True
End If
End If
Hack:
hi,Rss!seven is a plotting data point,will return many record from the query.rs1!Lcl is only return one data point for minimum scale Y from mschart.