Access Expression On Click Error for Form Button

Access Expression On Click Error

I use a couple of Access databases to run my business, and things usually go smoothly. Recently though, an error appeared when I clicked a button on the Main Menu form. The button was supposed to open a data entry form, and had worked perfectly for years. This time though, the other form didn’t open, and an Access Expression On Click Error appeared.

Access Expression On Click Error

Here’s a screen shot of the message that appeared when I clicked the form button:

Access Expression On Click Error for Form Button

The text in that image is pretty small (why are some error messages so wide?), so here’s the text version of the error message:

  • The expression On Click you entered as the event property setting produced the following error: Return without GoSub
  • The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure].
  • There may have been an error evaluating the function, event, or macro.

Confusing Message

None of that error message made any sense to me. “Return without GoSub”? What does that mean?

I was able to open the data entry form manually, by double-clicking it on the list of Forms in the Navigation pane. That was encouraging – the database wasn’t totally broken. But when I clicked a button in that data entry form , it showed the same error.

So, I closed and re-opened the database, hoping that the form button would miraculously heal itself. Unfortunately (and not surprisingly), that didn’t work.

Compile the Code

Over the many years that I’ve used Access, some problems can be fixed by compiling the code. It’s like the “Reboot your computer” tech support suggestion, for a database.

So, that was my next step in troubleshooting. Here’s how to compile the code in an Access database:

  • On the Database Tools tab, click the Visual Basic command, to open the Visual Basic Editor. Or, use the Alt + F11 shortcut to open the Visual Basic Editor.

accessformbuttonerror02

  • On the Debug menu, click Compile [your database name]

accessformbuttonerror03

  • Then, click the Save button, to save the changes
  • Close the Visual Basic Editor, to go back to Access.

Test the Button Again

Back in the database, I opened the Main Menu, and clicked the button again. It worked! The other data entry form opened, and I was back in business.

So, if you see a strange error message in Access, in a situation that worked perfectly before, try a compile and save, to see if that fixes the problem.

Other Solutions

If the compile and save doesn’t help, try a Compact and Repair Database (also on the Database Tools tab). That’s another command that fixes a multitude of Access database problems.

If that doesn’t work, try a Google search for the exact text in your error message. Somebody else has probably run into the same problem, and might have a suggestion on how to fix it.

And always have backups of your Access database, just in case you can’t repair the active file, especially if it’s a mission critical database. You don’t want to lose all your data, or spend days trying to rebuild, if something goes horribly wrong.

_______________

How to Fix an Access Expression On Click Error

Save

8 thoughts on “Access Expression On Click Error for Form Button”

  1. Thank you! I’ve confirmed it! I have been wondering why my Back Button isn’t working, so my first step was to Delete the whole code on the On Click Event and type the DoCmd.Close again. It works, but then again, the error appeared. That’s why I compiled the code and compacted and repaired the database, and it’s working. I even set the database when the database’ closes it will automatically compact and repair.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.