Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Click event not working

Posted on 2016-09-14
19
Medium Priority
?
42 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
  • 3
  • +2
19 Comments
 
LVL 51

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
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

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 39

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 18

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 39

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 39

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

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

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

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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, when working with VBA, learn some techniques for writing readable and easily maintained code.

688 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