Solved

Click event not working

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

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 34

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 34

Expert Comment

by:PatHartman
ID: 41799691
Can you post the test database that isn't working?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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 34

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now