The expression On Click you entered …

I was getting the below error message in Access 2003 when I clicked on a command button.  Likely because I was working on a form module and possibly saved it while the form was in regular view and not in design view.


“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.”


TheExpressionOnClick


Commenting all the code behind the form did not fix the problem. 


Setting the Has Module to No and saving the form, surprisingly, did not fix this problem.


Decompiling the MDB also did not fix the problem.


This problem also existed when I opened up the MDB in Access 2000 and clicked on a button on the form.


Importing all the objects into a new MDB finally did the job.


Hint: when importing lots of objects into a new MDB minimize the database container window before importing. Access will import much, much faster.


As a bonus a child sub form which wasn’t saving the parent value in the child table also started working properly. 


As a side note every hour or two I always go into Windows Explorer, click on the MDB and do a Ctrl+C and a Ctrl+V to copy the FE MDB.  Every few days I zip all those and move them to an archive folder.


Added:  I later figured out that I just needed to do a Save As of the troublesome form.

45 thoughts on “The expression On Click you entered …”

  1. Thank you so much for sharing this information. I am a VBA student and was stuck with the error. Your information has helped me tremendously.

  2. I’ve actually had this happen a couple of times over the last year or so while working on my current project (which finally goes into production tomorrow!). Importing all objects into a new container always fixed the problem. Anytime I start getting ‘odd’ errors I figure it’s time to import and it usually works to ‘cure’ the problem.

  3. I used to have a lot of Form tgat became corrupted. I changed allow design changes to Design View Only and it rarely occurs now. Before you import the entire database you can try this. Right click on the Form in the database window and save a copy. Rename the original Form in case you need it later. Then rename the new Form with the original Form name. This usually takes care of Form corruption.

    Best Regards,
    Pat Wood

  4. I wants to export all the objects into new MDB as you said, But i have lots of queries,macros,forms and Modules,

    I don’t know how we can export all together without doing it manually?

  5. Nirav. Think importing from the MDB. Not exporting. You can import from another MDB very nicely but I’m not really aware of any convenient means of exporting objects. (Without using SaveAsText and such but that’s much more advanced.)

  6. Well, dern. Been staring at this for hours. MS was no help, their solution is something about non-unicode characters.. which I I have none of. But this worked like a charm! They need to add this to their site.

    Thanks again!
    Matthew

  7. It worked! How messed up is that? I have been batteling this for a couple days thinking it was a connection problem and instead it’s a Microsoft thing. WOW!

  8. Worked for me as well, thanks for posting the fix! Luckily I hadn’t worked too long on trying to find the solution, maybe a bit over an hour, but it’s always frustrating when you find that it’s completely unrelated to your own code.

  9. Need help. When I get this message and click on “show Help” I get the following test in the box, “This error occurs when an event has failed to run because Microsoft Office Access cannot evaluate the location of the logic for the event. For example, if the OnOpen property of a form is set to =[Field], this error occurs because Access expects a macro or event name to run when the event is fired.” I ma stuck!

  10. Tony, Thanks for sharing this info on your site. I’m glad I read to the end of your post since Save As fixed my problem in a jiffy.

  11. Well Darn, had the same problem, and did a “Save As” to a new form, and now it works fine. Just to recap, in Access 2007 I built a form on a pre-existing query using the Create->Forms->More Forms->Datasheet option (sorry, pretend Access still has nice menus…), which clearly is buggy and results in a form to which code cannot be properly bound. Thanks Much!!

    Mike

  12. I am running into this problem on a couple of computers running the same mdb (always via Access 2003)from a portable HD. On most computers it’s not an issue. I’ll try the Save As… fix forthrightly.

  13. I have been having this and several other issues.
    I have a form with a number of subforms on a tab control If I have, or have had, *any* code on the main form the form fails – usually the communicating with the OLE server or ActiveX control one.
    If I remove the code it breaks the form giving #name? in any calculated controls and breaks the subform communication.
    I found that if I ran the performance analyser over the form collection and it prompts me to “Remove the module behind this form or report” and I “Optimize” all the problems are solved.
    As you can imagine it is very frustrating not being able to put code on the main form.

  14. As Pat Wood said above:
    1 copy your form
    2 check this copy is working
    3 replace the broken original

    It is something with the Layout View. You still can use this view, just keep in mind this you may need to repair the form once in a while.

  15. HI,

    I have had the same issue. I tried importing all the objects into a new database and it worked fine. But when I move the new database to an shared drive, it gives me the error again. Help please?

  16. I have this message coming up when I run my database in Access 2007, which has no problem in running in Access 2003. I don’t understand why. So it is not problem of ‘field’, nor the VBA codes, something to do with Access 2007.

  17. Thank you, thank you, thank you! I can’t believe that I struggled so long on something that had such a simple solution as to import the one form and four tables into a brand new Access 2003 database.

  18. Sometimes it is just related to buggy code
    here are some examples I faced previously:
    -having the same event more than once
    -having an invalid syntax in the event declaration. for example: BeforeUpdate(Cancel As Integer) if you omit the “Cancel As Integer” you might get that error
    -in the on open event having invalid “doCmd” code, for example having the below in a subform

    Private Sub Form_Open(Cancel As Integer)
    DoCmd.Maximize
    End Sub

    so always review the code of the event specified in the error, and dont forget to check any code in any of the subforms in the main form

  19. I had the same error:

    “The expression On Close you entered as the event property setting produced…” some freaking OLE error.

    I saw this property called “Fetch Defaults”… i was thinking WTF is that? it was set to ‘Yes’ so i set it to ‘No’ saved the page. And closed the form… damn if the error didn’t go away…

    but that wasn’t all… I reset the property back to ‘Yes’ just in case i broke something else …

    And SHA-ZAMM! the error wasn’t there either!!!

    MS you suck!

  20. I was getting the same error. But eventually found out that it was coming because of some missing references. In my case an mdb file it was searching for which was not present in designated folder.
    So make sure to check all your reference files if getting same error.

  21. I’ve tried this fix til I’m blue in the face…does not work. I’m not real familiar with Access, but we have a homegrown database that wouldn’t work with Access 2007 on our new work machines. It does work on Access 2003, so I had corporate install both versions on my machine. Worked fine.. THEN some new MS security update was pushed out to us and I came in to get this error now. So not an issue with the database but more with computer settings it seems. Can someone tell me in plain english what I need to do to fix this? Copying forms isn’t working.

  22. It’s great. Thank you for sharing this usefull experiences. It’s expected from MSDN to have this kind of information, even more compelete. Any way, thank you much.

  23. I had the same message trying to use the old switchboard menu I had created. What DIDN’T work was copying the database, removing such characters as dash “-” and slash “/” from code and menus. What DID work was weird since all I did was go to the on_click code and enter MSGBOX(“stop”) above the Case code. Sure enough the stop message popped up and when I closed it … No Message about error. When I closed database it asked if I wanted to save and I said yes. All fixed after that even after removing the msgbox entry and reswaving when it asked. Tried it on the copied database and it worked also. Looks like code just needed resaved???

  24. Thank you,,
    importing to new database solved this problem, it also repaired the size of my project from 46MB back to 10MB.

  25. I had this problem. All of the above solutions didn’t seem to have any effect. Turns out that I had misspelled the definition of a variable and the misspelling was the same as an object name. So, the variable and the object on the form were in conflict. Thanks for sensible messages Microsoft.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>