Professional Web Applications Themes

How do you activate a "COMMAND Button" with a macro? - Microsoft Access

How can you activate a command button with a macro? I have a "COMMAND BUTTON" called refresh, on a subform that works very well. I would like to activate this "COMMAND BUTTON" from the main form via a macro or very simple code....

  1. #1

    Default How do you activate a "COMMAND Button" with a macro?

    How can you activate a command button with a macro? I have
    a "COMMAND BUTTON" called refresh, on a subform that works
    very well. I would like to activate this "COMMAND BUTTON"
    from the main form via a macro or very simple code.
    RBB Guest

  2. #2

    Default Re: How do you activate a "COMMAND Button" with a macro?

    Wayne, By activate I mean run code behind button. What I
    want to do in a macro or VB code is just like I clicked on
    the command button. Thank you for your help. RBB
    >-----Original Message-----
    >By "activate" do you mean run the code behind the button
    or change the Enabled status of
    >the button?
    >
    >The VBA code for the latter from the main form would be:
    >Me.sfmNameOfSubformControl.Form.NameOfButton.Enab led =
    True
    >
    >The sfmNameOfSubformControl is the name of the control on
    the main form that holds the
    >subform, not the name of the subform itself, although
    they may be the same.
    >
    >--
    >Wayne Morgan
    >Microsoft Access MVP
    >
    >
    >"RBB" <BRADBLAKEAOL.COM> wrote in message
    news:02de01c3436a$dd27e700$a501280aphx.gbl...
    >> How can you activate a command button with a macro? I
    have
    >> a "COMMAND BUTTON" called refresh, on a subform that
    works
    >> very well. I would like to activate this "COMMAND
    BUTTON"
    >> from the main form via a macro or very simple code.
    >
    >
    >.
    >
    RBB Guest

  3. #3

    Default Re: How do you activate a "COMMAND Button" with a macro?

    Ok, I tried it from the main form, it should work from other locations as well.

    I had to change Private to Public in the name of the button's click event, then call it.
    Here is the code I used from the main form:

    Me.sfmNameOfSubformControl.Form.NameOfButton_Click

    --
    Wayne Morgan
    Microsoft Access MVP


    "RBB" <BRADBLAKEaol.com> wrote in message news:049901c3437a$a47ad3d0$a101280aphx.gbl...
    > Wayne, By activate I mean run code behind button. What I
    > want to do in a macro or VB code is just like I clicked on
    > the command button. Thank you for your help. RBB
    > >-----Original Message-----
    > >By "activate" do you mean run the code behind the button
    > or change the Enabled status of
    > >the button?
    > >
    > >The VBA code for the latter from the main form would be:
    > >Me.sfmNameOfSubformControl.Form.NameOfButton.Enab led =
    > True
    > >
    > >The sfmNameOfSubformControl is the name of the control on
    > the main form that holds the
    > >subform, not the name of the subform itself, although
    > they may be the same.
    > >
    > >--
    > >Wayne Morgan
    > >Microsoft Access MVP
    > >
    > >
    > >"RBB" <BRADBLAKEAOL.COM> wrote in message
    > news:02de01c3436a$dd27e700$a501280aphx.gbl...
    > >> How can you activate a command button with a macro? I
    > have
    > >> a "COMMAND BUTTON" called refresh, on a subform that
    > works
    > >> very well. I would like to activate this "COMMAND
    > BUTTON"
    > >> from the main form via a macro or very simple code.
    > >
    > >
    > >.
    > >

    Wayne Morgan Guest

  4. #4

    Default Re: How do you activate a "COMMAND Button" with a macro?

    Thanks for your help.
    >-----Original Message-----
    >Ok, I tried it from the main form, it should work from
    other locations as well.
    >
    >I had to change Private to Public in the name of the
    button's click event, then call it.
    >Here is the code I used from the main form:
    >
    >Me.sfmNameOfSubformControl.Form.NameOfButton_Clic k
    >
    >--
    >Wayne Morgan
    >Microsoft Access MVP
    >
    >
    >"RBB" <BRADBLAKEaol.com> wrote in message
    news:049901c3437a$a47ad3d0$a101280aphx.gbl...
    >> Wayne, By activate I mean run code behind button. What I
    >> want to do in a macro or VB code is just like I clicked
    on
    >> the command button. Thank you for your help. RBB
    >> >-----Original Message-----
    >> >By "activate" do you mean run the code behind the
    button
    >> or change the Enabled status of
    >> >the button?
    >> >
    >> >The VBA code for the latter from the main form would
    be:
    >> >Me.sfmNameOfSubformControl.Form.NameOfButton.Enab led =
    >> True
    >> >
    >> >The sfmNameOfSubformControl is the name of the control
    on
    >> the main form that holds the
    >> >subform, not the name of the subform itself, although
    >> they may be the same.
    >> >
    >> >--
    >> >Wayne Morgan
    >> >Microsoft Access MVP
    >> >
    >> >
    >> >"RBB" <BRADBLAKEAOL.COM> wrote in message
    >> news:02de01c3436a$dd27e700$a501280aphx.gbl...
    >> >> How can you activate a command button with a macro? I
    >> have
    >> >> a "COMMAND BUTTON" called refresh, on a subform that
    >> works
    >> >> very well. I would like to activate this "COMMAND
    >> BUTTON"
    >> >> from the main form via a macro or very simple code.
    >> >
    >> >
    >> >.
    >> >
    >
    >
    >.
    >
    rbb Guest

Similar Threads

  1. Turning off "Click to activate control" protectionfeature
    By javaJake in forum Macromedia Flash Player
    Replies: 3
    Last Post: November 30th, 10:58 PM
  2. "Press SPACEBAR or ENTER to activate and use thiscontrol"
    By YaSHaRz in forum Macromedia Flash Player
    Replies: 7
    Last Post: May 22nd, 08:14 AM
  3. "Weld" command in "Corel Draw"
    By Ayres_Ben@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 2
    Last Post: April 14th, 07:08 PM
  4. Replies: 0
    Last Post: August 7th, 08:59 PM
  5. Run Word's Macro from command button
    By Tim in forum Microsoft Access
    Replies: 1
    Last Post: July 21st, 03:51 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139