Object of class does not support the set of events HELP! (1 Viewer)

TheSafetyGuy86

Registered User.
Local time
Today, 05:22
Joined
Jun 18, 2013
Messages
31
I have a control box on a form that is set to locate a record on my form. For the past week and a half while developing this database, it has worked just fine. Now all of a sudden I get an error and it shuts down my macro.

"Object or class does not support the set of events."

I used the access wizard to create the box to "find a record on my form based on what is selected." So it is an macro that is ingrained into access to update the ID of the record selected and changes the rest of my form to that record.

Any ideas what is going on with this?
 

pr2-eugin

Super Moderator
Local time
Today, 10:22
Joined
Nov 30, 2011
Messages
8,498
What control are you using? I guess it is a ComboBox.. Anyway, convert the Macro to VBA and show us the Code..
 

TheSafetyGuy86

Registered User.
Local time
Today, 05:22
Joined
Jun 18, 2013
Messages
31
After trying, it wont let me. Says there is an error in converting the macro to code twice and then breaks. I can post the macro code though.

It is a "Search for Recrod" macro with no object name or type and the record is set to first. The where condition is this code

="[ID] = " & Str(Nz([Screen].[ActiveControl],0))
 

pr2-eugin

Super Moderator
Local time
Today, 10:22
Joined
Nov 30, 2011
Messages
8,498
Okay change it as..
Code:
="[ID] = " & Nz([Screen].[ActiveControl],0)
I am hoping ID is a Number type..
 

TheSafetyGuy86

Registered User.
Local time
Today, 05:22
Joined
Jun 18, 2013
Messages
31
Okay, I tried that and got the same error. Now I am a little confused because I tried to click the other functions on the form, such as the button that opens other forms and every one of the macros and codes is bringing back the same error. I checked other forms in my database and they are working fine, it is just this form so far. Why would it do this for ever macro and code on this form?
 

pr2-eugin

Super Moderator
Local time
Today, 10:22
Joined
Nov 30, 2011
Messages
8,498
What event is the macro set to run? AfterUpdate right? Can you show the screen shot of the properties tab for the ComboBox?
 

TheSafetyGuy86

Registered User.
Local time
Today, 05:22
Joined
Jun 18, 2013
Messages
31
Okay, so I copied everything on the form and pasted it into a new form. So far, no issues at all. Everything is working again. Not sure if it was something to do with that specific form, but now things are working. Like I said, every other form in the database worked fine except for that specific form. Not sure what happen, but at least now its up and running again.
 

pr2-eugin

Super Moderator
Local time
Today, 10:22
Joined
Nov 30, 2011
Messages
8,498
That's weird, well its working now.. Good.. :)
 

SOS

Registered Lunatic
Local time
Today, 02:22
Joined
Aug 27, 2008
Messages
3,517
Okay, so I copied everything on the form and pasted it into a new form. So far, no issues at all. Everything is working again. Not sure if it was something to do with that specific form, but now things are working. Like I said, every other form in the database worked fine except for that specific form. Not sure what happen, but at least now its up and running again.
Sounds like a bit of corruption occurred or the VBA got out of synch. That can happen at times and a DECOMPILE and then Compile again can help.
 

chellebell1689

Registered User.
Local time
Today, 02:22
Joined
Mar 23, 2015
Messages
267
Sounds like a bit of corruption occurred or the VBA got out of synch. That can happen at times and a DECOMPILE and then Compile again can help.

I was having the same problem, and since I don't have any VBA code, I just went to Database Tools > Compact & Repair Database.

(Thought I'd share in case anyone else is having a similar issue)
 

NutMegAccess

New member
Local time
Today, 18:22
Joined
Feb 5, 2021
Messages
1
This is an old thread but I have just encountered this issue myself and wanted to add some information for anyone else encountering this issue:
The "Object or class does not support the set of events." error occurred for me on a Form when using a ComboBox that selected an ID (Auto Generated Number type), this ID was then used in two consecutive queries to load data into two Report Subforms.

When I went in to try and change the Macro itself I tried changing it from
="[ID] = " & Str(Nz([Screen].[ActiveControl],0))
to
="[ID] = " & Nz([Screen].[ActiveControl],0)
as suggested above, but this resulted in a Type Mismatch. I closed and reopened the Macro to try something else and found that the unchanged code also resulted in a Type Mismatch.

Using the Database tool 'Compact and Repair Database' also had no effect.

I then tried deleting only the ComboBox and recreating it with the same name, and this seems to have resolved the issue for now.

Hope this helps someone else.
 

Isaac

Lifelong Learner
Local time
Today, 02:22
Joined
Mar 14, 2017
Messages
3,726
Shouldn't even be using screen.activecontrol. Never rely on 'active' or 'select' in excel or access vba. It's too uncertain. How do you know if Access will think the screen's activecontrol is the same thing you hope it might be?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 10:22
Joined
Sep 12, 2006
Messages
14,220
I've not read the whole thing, but screen.activecontrol is a control, not a string, so I am not surprised it doesn't work.
maybe you need a function to get the control name. Note that screen.activecontrol also depends on screen.activeform

Why do you need a macro at all? Can't you just write whatever you are doing in code?

eg - if you have a search string called searchtext, and want to search a control called Employeename

'this searches all the records for the first partial match
EmployeeName.SetFocus
DoCmd.FindRecord searchtext, acAnywhere, False, acSearchAll, False, acCurrent, True

'then this finds successive matches - note the final argument changes from true to false, so you don't search all the records
EmployeeName.SetFocus
DoCmd.FindRecord EmployeeName, acAnywhere, False, acSearchAll, False, acCurrent, False

It's same as Ctrl-H, or binoculars, but more user friendly, I think.
 
Last edited:

Users who are viewing this thread

Top Bottom