How to fix Error 459 Object or class does not support the set of events.

Error 459 in MS Access

This article is about to how to fix the error 459 Object or class does not support the set of events. This error mostly occurs when we are using any object or variable that is not supported in class. There are other reasons also. This error may occur after applying one or more of several Microsoft security updates and if class does not support automation or does not support expected interface.

Firstly to understand we have to reproduce this error. For that we have to create the Form as shown in Fig 1.1.

Error 459 Object or class does not support the set of events. Fig-1.1


After this we have to create two modules to test class A and class B. You will 459 "Object or Class does not support the set of elements" when assigning an object of class "A" to an object variable of class "B" in order to use an alternate interface as shown in Fig 1.2. The Visual Basic editors do not support events in inherited interfaces. WithEvents not supported the private User controls, because the type-info needed to raise the ObjectEvent not available at runtime. We cannot change the behavior of Visual editor. We can take it as limitation. For this particle example we can remove the WithEvents keyword from the objBC variable declaration. If we remove the Event declaration from the class A module, the editor compiler will also delete the WithEvents keyword on the variable declaration and code will executed without error.

Error 459 Object or class does not support the set of events. Fig-1.2


VBA Code on Button clicks:

Private Sub Command0_Click()
Set CLASSA_obj = New Derived_Class
Set CLASSB_obj = CLASSA_obj
CLASSB_obj.PostAlert " test message"
Set CLASSB_obj = Nothing
Set CLASSA_obj = Nothing
End Sub
Sub DC_Alert(ByVal Msg As String)
MsgBox Msg
End Sub

VBA Code for CLASS A Module:

Option Compare Database
Event Alert(ByVal Msg As String)
Public Sub PostAlert(ByVal Msg As String)
End Sub

VBA Code for CLASS B Module:

Option Compare Database
Implements Base_Class
Event Alert(ByVal Msg As String)
Private Sub Base_Class_PostAlert(ByVal Msg As String)
RaiseEvent Alert(Msg)
End Sub


It is advised that the information provided in the article should not be used for any kind formal or production programming purposes as content of the article may not be complete or well tested. Access Guru will not be responsible for any kind of damage (monetary, time, personal or any other type) which may take place because of the usage of the content in the article.