J
jtertin
I am using the below subroutine to load data for a MSChart control in
Access. The query "ChartData" is dynamically linked to a SQL linked
table. I wanted to take this approach so the chart would dynamically
adjust itself to the table regardless of the number of columns in the
recordset.
My problem is that the first column in my record set (columns below)
is a DateTime data type. I found that I could not use this timestamp
as labels for my X-Axis unless I cast it as a VARCHAR before using
it. However, if I do this, the X-Axis is no longer automatically
scaled, so when I get >50 points on my graph, they all run together.
Is there a way to make this work? Can an MSChart use (and
automatically scale) the DateTime data type as an X-Axis unit?
=============================================
Private Sub Form_Load()
Dim con As Object
Dim ChartRecordset As Object
Set con = Application.CurrentProject.Connection
Set ChartRecordset = CreateObject("ADODB.Recordset")
ChartRecordset.Open "SELECT * from [ChartData]", con, adOpenStatic,
adLockOptimistic
With Chart
Set .DataSource = ChartRecordset
.ShowLegend = True
End With
End Sub
=============================================
Record Set (Dyamic number of columns):
[dtDateTime],[Column1],[Column2],[Column3],[Column4]
I would like to use dtDateTime (in database as DateTime type) as
labels for my X-Axis
Access. The query "ChartData" is dynamically linked to a SQL linked
table. I wanted to take this approach so the chart would dynamically
adjust itself to the table regardless of the number of columns in the
recordset.
My problem is that the first column in my record set (columns below)
is a DateTime data type. I found that I could not use this timestamp
as labels for my X-Axis unless I cast it as a VARCHAR before using
it. However, if I do this, the X-Axis is no longer automatically
scaled, so when I get >50 points on my graph, they all run together.
Is there a way to make this work? Can an MSChart use (and
automatically scale) the DateTime data type as an X-Axis unit?
=============================================
Private Sub Form_Load()
Dim con As Object
Dim ChartRecordset As Object
Set con = Application.CurrentProject.Connection
Set ChartRecordset = CreateObject("ADODB.Recordset")
ChartRecordset.Open "SELECT * from [ChartData]", con, adOpenStatic,
adLockOptimistic
With Chart
Set .DataSource = ChartRecordset
.ShowLegend = True
End With
End Sub
=============================================
Record Set (Dyamic number of columns):
[dtDateTime],[Column1],[Column2],[Column3],[Column4]
I would like to use dtDateTime (in database as DateTime type) as
labels for my X-Axis