Results 1 to 12 of 12
  1. #1
    NKB is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    30

    Beginner: My first Event Procedure associated with OnClick button does not work? HELP.


    I created my first Form, and placed a command box button. I placed the following code:

    Private Sub Command335_Click()
    MsgBox "OK"
    End Sub

    I do not get the msgbox "OK" ? What is wrong? Please help.

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    I know it might seem obvious but is the buttons name command335?

    In design mode when you click on the button and look at the properties window, is there anything next to onclick (there should be)

    If there isn't then choose the enter code option.


    Sent from my iPhone using Tapatalk

  3. #3
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    It sounds like you have a button and a subroutine to run but no instruction in the properties window to tell it to run a subroutine.


    Sent from my iPhone using Tapatalk

  4. #4
    NKB is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    30
    I have the property set OK. The OnClick in the property sheet is set to point to the subroutine i posted above. Is there anything i need to do with options somewhere?

  5. #5
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Can you attach your database using advanced button on here?


    Sent from my iPhone using Tapatalk

  6. #6
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

    Beginner: My first Event Procedure associated with OnClick button does not work? HELP.

    Easier to see if I could see the db[emoji848]

  7. #7
    NKB is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    30
    OK here is the db:

    MyFirstDatabase.accdb

    I hope you can open it and help me find out the problem!!

  8. #8
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    I'm away from my pc for an hour but someone will sort it out. If not I'll have a look when I get home.


    Sent from my iPhone using Tapatalk

  9. #9
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    It works perfectly as is for me. Very straightforward. Form with one button, event procedure for on_click.

  10. #10
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Does any code execute? In version 2007 and later, when no VBA code executes, the problem is usually that the folder holding the database hasn’t been designated as a "Trusted" location.

    Have no idea, with v2016, where to find the Options, as they appear to change the location with each new version that comes out, but find Options then look for a tab marked Trust Center or something similar, and then set a trust location to the Folder the database resides in.

    Linq ;0)>

  11. #11
    NKB is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    30
    Linq,

    Wonderful! It worked. I went to File-Options-Trust Center and marked the location as trusted location and it worked. Thanks for the help. Indeed, this is a great Forum.

  12. #12
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Command button (event procedure)
    By Nathan23 in forum Forms
    Replies: 5
    Last Post: 08-15-2016, 07:52 AM
  2. Replies: 8
    Last Post: 04-23-2015, 06:12 AM
  3. Replies: 6
    Last Post: 10-11-2012, 02:19 PM
  4. Replies: 3
    Last Post: 05-07-2012, 12:17 PM
  5. Replies: 1
    Last Post: 10-06-2011, 02:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums