Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Class doesn't support automation error

Status
Not open for further replies.

IanAble

Programmer
Jan 24, 2005
112
GB
Hi All,

In Access 97 I've created a custom CommandBarButton on a custom Toolbar and I am trying to set a WithEvents reference to that button in a class module. When I run the sub procedure to set the reference I get the Error 430: Class doesn't support automation error.

Here's the code:
Code:
[COLOR=green]'Class Module Declaration:[/color]
Dim WithEvents btnClearSort As CommandBarButton

[COLOR=green]'Sub Procedure[/color]
Public Sub RefCommandBar()
'|Reference CommandBar Controls.|
On Error GoTo Err_RefCommandBar
Dim btnCommandbar As CommandBarButton
Dim strToolbar As String
    
    strToolbar = Forms(Forms.Count - 1).Toolbar
    If Not strToolbar = "" Then
        Set cbrToolbar = Application.CommandBars(strToolbar)
        For Each btnCommandbar In cbrToolbar.Controls
            If btnCommandbar.Caption = "Clear Sort" Then
                Set btnClearSort = btnCommandbar
            End If
        Next btnCommandbar
    End If
    
Exit_RefCommandBar:
    Exit Sub
  
Err_RefCommandBar:
    MsgBox "RefCommandBar Error: " & Err.Number & ": " & Err.Description
    Resume Exit_RefCommandBar
End Sub

I'm running this program on a XP SR2 machine, which also has Access 2K loaded. Any ideas as to what is causing this error?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top