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
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