Access Graph Automation Object Error

thrasher101

New Member
Joined
Jul 16, 2003
Messages
5
I am having problems with access graph automation. This code that I have been playing with from a VBA book I have been reading. The problem is two fold, on formload it gives me a type mismatch error and an ole operation failed to load error once started. I beleive the second error will be solved once the first is. This is the code in question...

Private Sub Form_Load()

' set a reference to the chart object
Set m_objChart = ctlChart.Object

End Sub


And here is the whole code.
If there is anything else I need to mention, feel free to mention it!
Thanks a lot!

Option Compare Database
Option Explicit

Private m_objChart As Graph.Chart
-----------------------------------------------
Private Sub cboCompany_Change()

On Error GoTo cboCompany_Change_Err

Dim strSQL As String

' different select statement for all records
strSQL = "qrysales"

' set the data source for the chart
ctlChart.RowSource = strSQL
ctlChart.RowSourceType = "Table/Query"

' format the chart
With m_objChart
' set the font size
.ChartArea.Font.Size = 8
.HasLegend = chkLegend
.Refresh

' If showing all then make multi-layered
If cbocompany = -1 Then
.ChartType = xl3DColumn
.Refresh
.Axes(xlSeriesAxis).HasTitle = False
Else
.ChartType = xl3DColumnStacked
.Refresh
End If

' format the x-axis
With .Axes(xlCategory)
.HasTitle = True
.AxisTitle.Caption = "Month"
End With

' format the y-axis
With .Axes(xlValue)
.HasTitle = True
.AxisTitle.Caption = "Total Sales"
End With

End With

cboCompany_Change_Exit:
Exit Sub

cboCompany_Change_Err:
If Err.Number = 1004 Then
m_objChart.Refresh
Else
Err.Raise Err.Number, Err.Source, Err.Description, Err.HelpFile,
Err.HelpContext
End If

End Sub
----------------------------------------
Private Sub chkLegend_Click()

m_objChart.HasLegend = chkLegend

End Sub
---------------------------------------------
Private Sub Form_Load()

' set a reference to the chart object
Set m_objChart = ctlChart.Object

End Sub
-------------------------------------------------
Private Sub Form_Unload(Cancel As Integer)

' clean up reference
Set m_objChart = Nothing

End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,221,621
Messages
6,160,879
Members
451,675
Latest member
Parlapalli

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top