Object or class does not support the set of events

  • Thread starter Thread starter parko
  • Start date Start date
P

parko

Guest
Can anyone help please?

I have just created a standard input form to enter job information. The only code behind the form is the code the wizard created for the OnClick event when I put a command button on the form to close the form down.

When I click the button I get the error message:-

"The expression on click you entered as the event property setting produced the following error: Object or class does not support the set of events."

This is doing my head in any suggestions will be greatly appreciated.

parko
 
Closing a form should be as simple as this in the OnClick event of your button...

DoCmd.Close acForm, Me.Name

or this but specifying the form name is not neccessary...

DoCmd.Close acForm, "YourFormName"

The wizard creates some funky code using old menu commands and should be avoided.
 
I know this, but there doesn't seem to be a solution to this type of problem, I've searched everywhere. And it is a common issue.

I mainly use the wizard for quick and simple button operations but clearly there is a bug somewhere.

Call me inquisitive but this sort of thing really bugs me if I don't know the solution to the problem.
 
G’day parko

Three things might help…

State the version of Access you are using in your profile, not all versions always behave the same.

Post all the code behind the form and that includes any options that are stated.

You also say 'And it is a common issue.' but do not say why you think that.

Regards,
Chris.
 
Hi Chris,

I'm running Access 2003 building Access 2000 format databases.

I say it's a common problem because some years ago I noticed certain forums bombarded with the same questions about the problem even with versions of Access '97. Nowhere could I find a solution to the error.

However about 5 years ago I was building a rather large complex database for a local company and was constantly dogged by the same error but after a lot of late nights (yes I was sad then) and trial and error I stumbled across the cause of the problem but can I hell think what it was. I recall messing about with some of the references in the VBA reference libraries. It is a nuisance because it can render a perfectly good form useless in functionality, and the error just appears anytime (but I've found that only when I use the wizard).

Anyway Chris enough of my life story here's what I've got:

A standard input form with it's recordsource "tblCustomers" table and 1 wizard generated command button to close the form.

The wizard generated code is as follows:

Option Compare Database
Option Explicit

Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click

DoCmd.Close

Exit_cmdClose_Click:
Exit Sub

Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click

End Sub

Just as I would expect.

Look forward to your reply Chris.

Dave
 
parko said:
The wizard generated code is as follows:

Option Compare Database
Option Explicit

Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click

DoCmd.Close

Exit_cmdClose_Click:
Exit Sub

Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click

End Sub
I recommend that you define what to close.

Code:
DoCmd.Close [B][COLOR=Blue]acForm[/COLOR][/B], Me.Name
 
Well I always use the method a stated by ghudson only because DoCmd.Close closes the form with the focus. In this case the form running the code must have the focus because the code is in a Private Sub and therefore must have been called from within that form. Anyhow that’s another story and I doubt if it is the problem here.

But I have not seen the problem before.

Whenever I see 'large complex database' mentioned I start to think when the last time it was decompiled.

Apart from that can the problem be reproduced in a small enough demo for posting?
If we can verify, one way or the other, that it works on another machine we may start to get somewhere.

That’s about the best I can suggest at the moment. :(

Regards,
Chris.
 
Possible Resolution

I encountered this same error recently. It was resolved by obtaining (from another machine) a copy of mscomct2.ocx.

In my case, the version I used was dated 5/21/2000 and its exact size was 647,872 bytes.
  • Copy it to C:\Windows\System32
  • Register it: regsvr32 c:\windows\system32\MSCOMCT2.OCX

Good Luck.
Pete
 
My Solution

I encountered this same error recently. It was resolved by obtaining (from another machine) a copy of mscomct2.ocx.

In my case, the version I used was dated 5/21/2000 and its exact size was 647,872 bytes.
  • Copy it to C:\Windows\System32
  • Register it: regsvr32 c:\windows\system32\MSCOMCT2.OCX

Good Luck.
Pete

Im just putting it out there for anybody that it might help. I got the same error in excel when trying to dynamically add a checkbox control to the sheet. I found that when I declared the object directly as a checkbox I got the error

Dim WithEvents chkBox1 As CheckBox

However when it was declared from the MSForms class the error was no more

Dim WithEvents chkBox2 As MSForms.CheckBox
 
I encountered this same error recently. It was resolved by obtaining (from another machine) a copy of mscomct2.ocx.

In my case, the version I used was dated 5/21/2000 and its exact size was 647,872 bytes.
  • Copy it to C:\Windows\System32
  • Register it: regsvr32 c:\windows\system32\MSCOMCT2.OCX

Good Luck.
Pete

I tried this. I tracked down the MSCOMCT2.ocx file, registered it, and I have the same "Object or class does not support the set of events " error with a Access 2003 DB. :(
 
I have this same problem happen to me in an Access 2000 Database. Here's the really bizarre part. If I have someone else opens it, clicks on a button and then closes it (the button works for them), then when I open the database and click on the button, it works for me. After I close the database, re-open it, and click the same button again, I get the error again. I tried grabbing the MSCOMCT2.OCX file from the other persons machine, copying it over, and registering it, and that didn't work.

I've also tried reinstalling my entire Office 2000 suite. Still get the same issue. Also, we have MANY Access 2000 Databases, and only a few of them do this to me. I cannot find the commonality between the bad ones.

Does anyone have any other options?
 
Solved the problem by creating a new empty database and used:
File/Get External Data/Import...
To select and import all objects from the corrupted database.
The above mentioned decompile will be more effective, but this is a "quicky" :-)

Nic;o)
 
Hi All,

I'm having the same problem..and I did not found any solution in the web. Anyway, I would like to share what I found out...

The reason behind these errors is the version used for the development of the MSAccess App. I have MSAccess 2002 and 2007 both installed in my workstation. Since I installed the 2007, the 2002 version produces this error: "Object or class does not support the set of events" everytime I ran VBA.

Anyways, to make the long story short use the correct "MSACC.OLB" for the right version of the MSAccess. Check the reference used in VBA to see if the right version of the said file is being used.

here are the list of paths for this file:

2007 = "C:\Program Files\Microsoft Office\Office12"
2003 = "C:\Program Files\Microsoft Office\Office11" << not sure with this one
2002 = "C:\Program Files\Microsoft Office\Office10"
...
97 = "C:\Program Files\Microsoft Office\Office" << MSACC8.OLB is used

You may change the path of the refrence used in VBA or you may just replace it with your preferred version of the OLB file(just rename the old one).

I hope this will help everyone!
 
I too have both Office 2003 and 2007 co-installed on my machine. When I open an Access 2003 database, and any form or report, this error came up. My solution is to "toggle" a Reference - "Microsoft Office 11.0 Object Library" - untick it, close References dialog, re-open it, and click Browse to navigate to the MSO.DLL file in the OFFICE11 folder under "microsoft shared" folder
 
tandy279

I also have have the 2002 and the 2007 loaded on my computer. I'm getting the same error trying to open a 2000
db format in 2002.

""toggle" a Reference - "Microsoft Office 11.0 Object Library" - untick it, close References dialog, re-open it, and click Browse to navigate to the MSO.DLL file in the OFFICE11 folder under "microsoft shared" folder"

Where is the reference Object Library located. How do i access it?

Thanks

B_rocks
 
try this location:

C:\Program Files (x86)\Common Files\microsoft shared\OFFICE11\MSO.DLL

I'm running Windows 7 hence there're two "Program Files" folders on my C drive. Yours could be without "(x86)" suffix.

after my initial comment, I found that this approach doesn't always solve the problem. sometimes I also need to toggle the Excel 11.0 reference. Office doesn't co-exist very well with its own predecessors.
 
Thank you, I'll give it a try.

Happy Holidays.

B.





try this location:

C:\Program Files (x86)\Common Files\microsoft shared\OFFICE11\MSO.DLL

I'm running Windows 7 hence there're two "Program Files" folders on my C drive. Yours could be without "(x86)" suffix.

after my initial comment, I found that this approach doesn't always solve the problem. sometimes I also need to toggle the Excel 11.0 reference. Office doesn't co-exist very well with its own predecessors.
 
As a follow up, I ran into the same problem. In my case I had installed Access 2010 runtime after 2003.
While running Access 2003 full version, the references showed "Microsoft Access 14 Object Library". It should have been 11.0 not 14.
1) I shut down Access, renamed the file for Rintime 2010 - "C:\Program Files\Microsoft Office\Office14\MSACC.OLB" to ...\MSACC.TMP.
2) Restarted Access 2003 and it worked!
3) Then renamed the originally file back.
 
I know this is an old thread but I can report the problem still occurs with a clash between Access versions. I had a client with Office Professional 2003 and Access 2010 installed alongside for some time. This error started to occur (presumably after some MS update) and was solved by uninstalling Access 2003 from the Professional suite.

Steve
 

Users who are viewing this thread

Back
Top Bottom