Solved

Click event not working

Posted on 2016-09-14
19
37 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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 36

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 15

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 36

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 36

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

821 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