Results 1 to 9 of 9

Thread: runtime error 3021

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    584

    runtime error 3021

    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.
    Attached Images Attached Images  
    Last edited by gracehskuo; Jun 15th, 2008 at 09:53 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width