Solved

Click event not working

Posted on 2016-09-14
19
36 Views
Last Modified: 2016-10-05
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.
0
Comment
Question by:DColin
  • 8
  • 6
  • 3
  • +2
19 Comments
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 41798418
Delete all this code and recreate it by typing, not copy and paste.

/gustav
0
 

Author Comment

by:DColin
ID: 41798510
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
 
LVL 75
ID: 41798515
Make a backup of your db first, then run this Decompile procedure (attached)
aaQicPostDecompile.txt
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:DColin
ID: 41798690
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
 
LVL 35

Expert Comment

by:PatHartman
ID: 41798723
This is not a web database is it?
0
 
LVL 75
ID: 41798732
Maybe time to run Office repair.  This makes no sense
0
 
LVL 13

Expert Comment

by:John Tsioumpris
ID: 41799243
Msgbox "ABC" is to display the message
Msgbox ("ABC",vbyesNo) to get the response
0
 

Author Comment

by:DColin
ID: 41799301
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
 
LVL 35

Expert Comment

by:PatHartman
ID: 41799691
Can you post the test database that isn't working?
0
 

Author Comment

by:DColin
ID: 41800020
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
 
LVL 75
ID: 41800190
Both buttons work for me ... message appears.
0
 
LVL 75
ID: 41800200
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
 

Author Comment

by:DColin
ID: 41800299
DatabaseMX,

The Debug>Compile option is greyed out. How do I make it available?
0
 
LVL 35

Expert Comment

by:PatHartman
ID: 41800323
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
 

Author Comment

by:DColin
ID: 41800406
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
 
LVL 75
ID: 41800457
Correct ...no errors.

Try running an Office Repair ... this is REALLY strange !
0
 

Accepted Solution

by:
DColin earned 0 total points
ID: 41800574
Found the problem.

Access Options>Trust Center>Trust Center Settings>Macro Settings>Enable All Macros
0
 
LVL 75
ID: 41800624
OOPS ... so simple yet so easy to miss.  Bad on us :-)
0
 

Author Closing Comment

by:DColin
ID: 41829526
Found the answer myself but appreciate the help in trying to solve the problem.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question