Click event not working

Hi Experts,

I have a simple click event on a form that is not working:

Private Sub btnABC_Click()

    MsgBox ("ABC")

End Sub

When I go to the buttons properties On Click [Event Procedure] is shown and if I click on the ellipses it opens the Code page with the cursor on the correct event.
DColinAsked:
Who is Participating?
 
DColinConnect With a Mentor Author Commented:
Found the problem.

Access Options>Trust Center>Trust Center Settings>Macro Settings>Enable All Macros
0
 
Gustav BrockCIOCommented:
Delete all this code and recreate it by typing, not copy and paste.

/gustav
0
 
DColinAuthor Commented:
Gustav Brock,

Still does not work.

If I type =MsgBox("ABC") into the On Click property then it works but hot from a coded on click event.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Make a backup of your db first, then run this Decompile procedure (attached)
aaQicPostDecompile.txt
0
 
DColinAuthor Commented:
DatabaseMX,

I did not carry out your instructions, I did the following instead.

I created a completely new Db added a single button to a blank form and added the line

MsgBox ("ABC")

to the on click event and it does not work. If I add the line

=MsgBox ("ABC")

to the On click property of the button it does work.

I do not think any form of DB corruption is my problem.
0
 
PatHartmanCommented:
This is not a web database is it?
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Maybe time to run Office repair.  This makes no sense
0
 
John TsioumprisSoftware & Systems EngineerCommented:
Msgbox "ABC" is to display the message
Msgbox ("ABC",vbyesNo) to get the response
0
 
DColinAuthor Commented:
The Access Form I am trying to create is on a new Office 365 installation. I have never created a form on this computer before.

Is there some master switch that needs to be set for the code to execute?
0
 
PatHartmanCommented:
Can you post the test database that isn't working?
0
 
DColinAuthor Commented:
PatHartman,

Please find attached.

btnABC On Click event is defined in the code and does not work.

btnABC2 On Click event is defined in it's properties and does work.
Database11.accdb
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Both buttons work for me ... message appears.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Do you then have the Click To Run version .... sounds like you do (I do also on this system in fact).
Open the VBA editor ... Debug>>Compile ... just check to see if it compiles - relative to any possible Missing References.

In fact, Tools>>References ... look for any listed as
**MISSING <SomeReferenceName>
0
 
DColinAuthor Commented:
DatabaseMX,

The Debug>Compile option is greyed out. How do I make it available?
0
 
PatHartmanCommented:
It is greyed out when the project is in a compiled state.  To activate it, make a change to the code.  Adding a blank line is sufficient.

Both buttons also work for me.  I'm using O2016 32-bit  from O365 on Win10
0
 
DColinAuthor Commented:
I added a few blank lines compiled the code and nothing seemed to happen the compile menu option is now greyed out again. Does that mean there were no errors.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Correct ...no errors.

Try running an Office Repair ... this is REALLY strange !
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
OOPS ... so simple yet so easy to miss.  Bad on us :-)
0
 
DColinAuthor Commented:
Found the answer myself but appreciate the help in trying to solve the problem.
0
All Courses

From novice to tech pro — start learning today.