OWC10 embedded in Report

S

Spiller Delicate

Hi,

I've embedded an OWC10.Chartspace (Chartspace1) into my Access Report. On
Format Event, I want to format the chart to details of the recordset. It
works fine the first time I call the report. If I reload the report, Access
hangs and displays nothing.

I thought the problem could be in freeing resources. But I'm using set
objchart = nothing already. Doesnt seem to work. Here's the code:

Dim objChart As New OWC10.ChartSpace
Dim categories(10)
Dim values(10)
Dim chConstants

'set constants
Set chConstants = ChartSpace1.Constants
'assign to present chartspace
Set objChart = ChartSpace1.Object

' Clear the contents of the chart workspace. This removes
' any old charts that may already exist and leaves the chart
workspace
' completely empty. One chart object is then added.
objChart.Clear
objChart.Border.Weight = 0
objChart.Charts.Add
With objChart.Charts(0)
.Type = chChartTypeBarStacked
'.Type = chChartTypeBarStacked3D
.HasTitle = True
'.ChartDepth = 25
.Border.Weight = 0
End With
' Add series to the chart.
objChart.Charts(0).SeriesCollection.Add
' Series one contains the mark.
' Set the categories for the first series (this collection is
zero-based)
objChart.Charts(0).SeriesCollection(0).SetData
chConstants.chDimCategories, chConstants.chDataLiteral, categories
objChart.Charts(0).SeriesCollection(0).SetData
chConstants.chDimValues, chConstants.chDataLiteral, values
objChart.Charts(0).SeriesCollection(0).Caption = sTitle


With objChart.Charts(0).Axes(0)
.Font.Size = 8
.Position = chAxisPositionLeft
End With

'set scaling

objChart.Charts(0).SeriesCollection(0).Scalings(chConstants.chDimValues).Min
imum = 0

objChart.Charts(0).SeriesCollection(0).Scalings(chConstants.chDimValues).Max
imum = 100

With objChart.Charts(0).Axes(1)
.HasTickLabels = False
.MajorTickMarks = chTickMarkNone
.HasAutoMajorUnit = False
.HasAutoMinorUnit = False

.HasMajorGridlines = False
.HasMinorGridlines = False

.HasTitle = True

.Title.Caption = "<< POOR
EXCELLENT >>"
.Title.Font.Name = "Arial"
.Title.Font.Size = 8


End With
' Make the chart legend visible, format the left value axis as
percentage,
' and specify that value gridlines are at 10% intervals.
objChart.Charts(0).HasLegend = False

'ChartSpace1.Charts(0).Axes(chConstants.chAxisPositionLeft).NumberFormat =
"0%"
End If

'free all resources
Set objchart = nothing
 

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