MS Access - Forms - VBA Code with Command Click

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kylegrenier
    New Member
    • Apr 2015
    • 2

    MS Access - Forms - VBA Code with Command Click

    Hello All,

    This hopefully is a question that in theory should be very simple for someone to answer.

    I've created a basic Form and "Button" then "built the event" and pasted in my VBA code for the event.

    All I need to do now is have the code execute when the button is clicked.

    Can anyone help me with the steps to do so?

    I am not a programmer and for this button these are series of basic "update queries" that need to be run.

    Alternatively, if I can execute a module (vs pasting in the code as an event) this same way with a button that would also work.

    Regards,

    Kyle
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    In the properties window, select the Event tab and select the On Click line. An elipsis button (three dots) will appear. click it and that will create the event procedure that will run when it is clicked, or it will tie the event to the procedure you have already in place if it is setup correctly. You can also call the name of your procedure (assuming that the proper Private/Public assignment was given to it and depending on the location relationship between the event and your procedure) from the OnClick event.

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      Just to build on Seth...
      Follow Seth's instructions, this will insert
      Code:
      Private Sub Command11_Click()
      'Cut and paste your code here :)
      '
      End Sub
      Command11 is a generic name, it will be replaced by the name you gave your button when you created it... or if you used the default name... then it might actually match :)

      Comment

      • kylegrenier
        New Member
        • Apr 2015
        • 2

        #4
        Thank you both!! Sorry for the late reply, I assumed I would get an email telling me someone responded. That was, as I suspected very easy.

        Comment

        Working...