Solved

Click event not working

Posted on 2016-09-14
19
40 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 50

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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 37

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 17

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 37

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 37

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

739 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