第一行数据有时会作为X轴每个点的文本, 数据类型是字符还是数字,忘了, 试试就知道了, 不知道你是否是这种情况。 ^_^不要瞎猜。这就是MSChart的缺陷,它不会自动移位到第一条记录。见资料: ***************************************************************** Avoid the MSChart glitch when displaying ADO Recordset data When you assign an ADO Recordset to an MSChart's DataSource property, the resulting chart may not contain the first row of data. Normally, when you create a Recordset object, ADO automatically moves the cursor to the first record (assuming the recordset contains records). As a result, there's no need to issue the MoveFirst command. Unfortunately, unless you issue this command, MSChart skips over the first record for some reason. As a result, when you use the MSChart control with an ADO Recordset, always move the cursor to the first record before you assign it to the chart, as seen here:Dim rst As ADODB.Recordset Dim sql As String Set rst = New ADODB.Recordset sql = "SELECT * FROM tblChartData" With rst .ActiveConnection = "Provider=Microsoft.Jet" & _ ".OLEDB.4.0;Data Source=D:\DBPath\db1.mdb" .Open sql, , adOpenStatic .MoveFirst End With Set MSChart1.DataSource = rst rst.Close Set rst = Nothing *****************************************************************
数据类型是字符还是数字,忘了,
试试就知道了,
不知道你是否是这种情况。
^_^不要瞎猜。这就是MSChart的缺陷,它不会自动移位到第一条记录。见资料:
*****************************************************************
Avoid the MSChart glitch when displaying ADO Recordset data
When you assign an ADO Recordset to an MSChart's DataSource property, the resulting chart may not contain the first row of data. Normally, when you create a Recordset object, ADO automatically moves the cursor to the first record (assuming the recordset contains records). As a result, there's no need to issue the MoveFirst command. Unfortunately, unless you issue this command, MSChart skips over the first record for some reason. As a result, when you use the MSChart control with an ADO Recordset, always move the cursor to the first record before you assign it to the chart, as seen here:Dim rst As ADODB.Recordset
Dim sql As String
Set rst = New ADODB.Recordset
sql = "SELECT * FROM tblChartData"
With rst
.ActiveConnection = "Provider=Microsoft.Jet" & _
".OLEDB.4.0;Data Source=D:\DBPath\db1.mdb"
.Open sql, , adOpenStatic
.MoveFirst
End With
Set MSChart1.DataSource = rst
rst.Close
Set rst = Nothing
*****************************************************************