using a datasource to populate more than one series ??

P

patrick

In an MS Access form I am trying to create a stacked barchart with more than one series - or any sort of chart with more than one series! All the examples I can find use hard-coded literal values for the series, but I need to use a datasource. When I do this i get a runtime error "invalid procedure call or argument" when using setdata to assign the values to the series. Code (based on the MSDN examples) is below. Any help anyone please?

Dim rst As New ADODB.Recordset
Const adcmdtable = 1
Const adopenstatic = 3
Const adlockreadonly = 1
Dim owcchartsp As New OWC10.ChartSpace

rst.Open "qryGantt", CurrentProject.Connection, adopenstatic, adlockreadonly
Set owcchartsp.DataSource = rst

Dim owcchart
Dim oseries1
Dim oseries2
owcchartsp.Clear
Set owcchart = owcchartsp.Charts.Add()
Set c = owcchartsp.Constants

owcchartsp.Charts(0).Type = c.chChartTypeBarStacked
Set oseries1 = owcchartsp.Charts(0).SeriesCollection.Add
Set oseries2 = owcchartsp.Charts(0).SeriesCollection.Add

oseries1.Caption = "StartDate"
oseries1.Name = oseries1.Caption
oseries1.SetData c.chDimCategories, 0, "projectname"
oseries1.SetData c.chDimValues, 0, "startdate"
 
T

Thao Moua [ms]

Creating a literal chart and a databounded chart is very
different. For a literal chart, you need to create a
chart, then a series, and then bind the data to the
series. For the data source case, you only need to bind
to the data source, specify at least a series name, a
category, and a value. The chart will take care of
creating the series and binding the series to the data.

You code should look something like this.

set c=webchart.constants
webchart.setdata c.chDimSeriesNames, 0, "foo" -> this
will use to create individual series for your chart
webchart.SetData c.chDimCategories, 0, "projectname"
webchart.SetData c.chDimValues, 0, "startdate"

FYI: when a Chartspace object is bounded to a data
source, a chart is created for you. So there is no need
to create another chart.

Thao Moua
OWC Webchart Support

This posting is provided "AS IS" with no warranties, and
confers no rights. Use of included script samples are
subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
-----Original Message-----
In an MS Access form I am trying to create a stacked
barchart with more than one series - or any sort of chart
with more than one series! All the examples I can find
use hard-coded literal values for the series, but I need
to use a datasource. When I do this i get a runtime
error "invalid procedure call or argument" when using
setdata to assign the values to the series. Code (based
on the MSDN examples) is below. Any help anyone please?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top