Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Autoexec sub

Discussion in 'Information Technology' started by Vern Rabe, Jul 28, 2006.

Tags:
  1. Vern Rabe

    Vern Rabe
    Expand Collapse
    Guest

    This is probably simple, but I'm stumped. How do you automatically execute a
    sub on load? None of the "Run" commands in the action drop down for the
    Autoexec macro seem to work with a sub.

    Thanks
    Vern
     
  2. Loading...

    Similar Threads Forum Date
    Movies Want movie Subeg Singh Shahbaz Singh Theatre, Movies & Cinema Jan 12, 2016
    United Sikhs Sikh woman sues suburban go-kart park after hair cut from motor Sikh Organisations Jan 9, 2014
    World Milkha Singh-inspired character makes appearance on Subway Surfers Breaking News Jan 7, 2014
    The Inner Experience and the Subconscious Mind Interfaith Dialogues Dec 6, 2013
    Opinion 1984 Sikh Genocide Petition To Be Submitted To The UN Breaking News Oct 23, 2013

  3. Rick Brandt

    Rick Brandt
    Expand Collapse
    Guest

    Vern Rabe wrote:
    > This is probably simple, but I'm stumped. How do you automatically
    > execute a sub on load? None of the "Run" commands in the action drop
    > down for the Autoexec macro seem to work with a sub.
    >
    > Thanks
    > Vern


    Make it a function. All it takes is changing a few words.

    --
    Rick Brandt, Microsoft Access MVP
    Email (as appropriate) to...
    RBrandt at Hunter dot com
     
  4. Vern Rabe

    Vern Rabe
    Expand Collapse
    Guest

    Rick:

    Thanks. That worked... kinda. When I create a function in a "local" module,
    it works. But I have a reference to another Access database, in which the sub
    (now function) resides. I can't seem to have the referenced one show up as a
    function for the Autoexec macro. Suggestions?

    Thanks
    Vern Rabe

    "Rick Brandt" wrote:

    > Vern Rabe wrote:
    > > This is probably simple, but I'm stumped. How do you automatically
    > > execute a sub on load? None of the "Run" commands in the action drop
    > > down for the Autoexec macro seem to work with a sub.
    > >
    > > Thanks
    > > Vern

    >
    > Make it a function. All it takes is changing a few words.
    >
    > --
    > Rick Brandt, Microsoft Access MVP
    > Email (as appropriate) to...
    > RBrandt at Hunter dot com
    >
    >
    >
     
  5. Rick Brandt

    Rick Brandt
    Expand Collapse
    Guest

    Vern Rabe wrote:
    > Rick:
    >
    > Thanks. That worked... kinda. When I create a function in a "local"
    > module, it works. But I have a reference to another Access database,
    > in which the sub (now function) resides. I can't seem to have the
    > referenced one show up as a function for the Autoexec macro.
    > Suggestions?


    How are you referrring to it? Are you inlcuding the referenced file in the call
    like....

    =FileName.Function()


    --
    Rick Brandt, Microsoft Access MVP
    Email (as appropriate) to...
    RBrandt at Hunter dot com
     
  6. Vern Rabe

    Vern Rabe
    Expand Collapse
    Guest

    Rick:

    By going to the Visual Basic Editor, Tools menu, References... menu, and
    adding a reference to the .mdb that has the function.

    Vern

    "Rick Brandt" wrote:

    > Vern Rabe wrote:
    > > Rick:
    > >
    > > Thanks. That worked... kinda. When I create a function in a "local"
    > > module, it works. But I have a reference to another Access database,
    > > in which the sub (now function) resides. I can't seem to have the
    > > referenced one show up as a function for the Autoexec macro.
    > > Suggestions?

    >
    > How are you referrring to it? Are you inlcuding the referenced file in the call
    > like....
    >
    > =FileName.Function()
    >
    >
    > --
    > Rick Brandt, Microsoft Access MVP
    > Email (as appropriate) to...
    > RBrandt at Hunter dot com
    >
    >
    >
     
  7. Rick Brandt

    Rick Brandt
    Expand Collapse
    Guest

    Vern Rabe wrote:
    > Rick:
    >
    > By going to the Visual Basic Editor, Tools menu, References... menu,
    > and adding a reference to the .mdb that has the function.


    I'm not certain that you don't still need to include the file name in the call.

    --
    Rick Brandt, Microsoft Access MVP
    Email (as appropriate) to...
    RBrandt at Hunter dot com
     
  8. Vern Rabe

    Vern Rabe
    Expand Collapse
    Guest

    Rick:

    When I go to design mode for the AutoExec macro, and select RunCode as the
    action, I am given a Function Name control to fill in. When I select the
    ellipsis in the control, it takes me to the Expression Builder window. There
    I can select only local functions (functions in referenced applications are
    not listed). If, back in the Function Name control, I explicitly type in
    "fnX()", it will run the local fnX function. If I instead type in
    "=RefApp.fnX()", attempting to save will result in an error message that
    Access cannot parse it. By eliminating the equal sign, and typing in
    "RefApp.fnX", the expression is parsed, but when I open the application I get
    an error that it can find the name "fnX". Could it be that Access is trying
    to run the code before the referenced code has been retrieved?

    Thanks
    Vern Rabe


    "Rick Brandt" wrote:

    > Vern Rabe wrote:
    > > Rick:
    > >
    > > By going to the Visual Basic Editor, Tools menu, References... menu,
    > > and adding a reference to the .mdb that has the function.

    >
    > I'm not certain that you don't still need to include the file name in the call.
    >
    > --
    > Rick Brandt, Microsoft Access MVP
    > Email (as appropriate) to...
    > RBrandt at Hunter dot com
    >
    >
    >
     
  9. Douglas J. Steele

    Douglas J. Steele
    Expand Collapse
    Guest

    Try creating a function in your local application that calls the function
    from the referenced application and call it from the AutoExec.

    That should indicate if it's trying to run too soon.

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no e-mails, please!)


    "Vern Rabe" <VernRabe@discussions.microsoft.com> wrote in message
    news:6BD105F7-9126-40A9-8A9C-6195C4D7D270@microsoft.com...
    > Rick:
    >
    > When I go to design mode for the AutoExec macro, and select RunCode as the
    > action, I am given a Function Name control to fill in. When I select the
    > ellipsis in the control, it takes me to the Expression Builder window.

    There
    > I can select only local functions (functions in referenced applications

    are
    > not listed). If, back in the Function Name control, I explicitly type in
    > "fnX()", it will run the local fnX function. If I instead type in
    > "=RefApp.fnX()", attempting to save will result in an error message that
    > Access cannot parse it. By eliminating the equal sign, and typing in
    > "RefApp.fnX", the expression is parsed, but when I open the application I

    get
    > an error that it can find the name "fnX". Could it be that Access is

    trying
    > to run the code before the referenced code has been retrieved?
    >
    > Thanks
    > Vern Rabe
    >
    >
    > "Rick Brandt" wrote:
    >
    > > Vern Rabe wrote:
    > > > Rick:
    > > >
    > > > By going to the Visual Basic Editor, Tools menu, References... menu,
    > > > and adding a reference to the .mdb that has the function.

    > >
    > > I'm not certain that you don't still need to include the file name in

    the call.
    > >
    > > --
    > > Rick Brandt, Microsoft Access MVP
    > > Email (as appropriate) to...
    > > RBrandt at Hunter dot com
    > >
    > >
    > >
     
  10. Vern Rabe

    Vern Rabe
    Expand Collapse
    Guest

    Douglas:

    I tried that, and it worked. My local function executes "intVar =
    FileName.ModName.fnX()". As a test, I then put a second action in the
    AutoExec, this one a RunCode that directly calls the referenced function
    (what I've been trying to do all along). On the assumption that the actions
    are executed synchronously, and since the first action includes a call to the
    referenced file, then when it comes time to run the second action, I'm
    assuming the referenced file has to be fully loaded. When I start the
    application with those in place I get the same
    "...can't find the name..." error. Does this mean my syntax is incorrect? Or
    it simply won't work this way?

    I have hundreds of Access apps that need to have this code run on startup.
    My hope is to go to each app, add a reference to my "shared" app, and add a
    RunCode action to the AutoExec macro. If that doesn't work, and I need to
    implement something like your Douglas', I would go to each app, add a
    reference to my "shared" app, add a module (most apps won't have one), add a
    function in this new module that calls the referenced app, and add a RunCode
    action to the AutoExec macro to run the new local function. Definitely
    doable, but more work, and if direct autoexec of a referenced function should
    work, I'd rather get it to work. So... should I stop here and implement this,
    or does anyone have any other ideas?

    Thanks
    Vern Rabe


    "Douglas J. Steele" wrote:

    > Try creating a function in your local application that calls the function
    > from the referenced application and call it from the AutoExec.
    >
    > That should indicate if it's trying to run too soon.
    >
    > --
    > Doug Steele, Microsoft Access MVP
    > http://I.Am/DougSteele
    > (no e-mails, please!)
    >
    >
    > "Vern Rabe" <VernRabe@discussions.microsoft.com> wrote in message
    > news:6BD105F7-9126-40A9-8A9C-6195C4D7D270@microsoft.com...
    > > Rick:
    > >
    > > When I go to design mode for the AutoExec macro, and select RunCode as the
    > > action, I am given a Function Name control to fill in. When I select the
    > > ellipsis in the control, it takes me to the Expression Builder window.

    > There
    > > I can select only local functions (functions in referenced applications

    > are
    > > not listed). If, back in the Function Name control, I explicitly type in
    > > "fnX()", it will run the local fnX function. If I instead type in
    > > "=RefApp.fnX()", attempting to save will result in an error message that
    > > Access cannot parse it. By eliminating the equal sign, and typing in
    > > "RefApp.fnX", the expression is parsed, but when I open the application I

    > get
    > > an error that it can find the name "fnX". Could it be that Access is

    > trying
    > > to run the code before the referenced code has been retrieved?
    > >
    > > Thanks
    > > Vern Rabe
    > >
    > >
    > > "Rick Brandt" wrote:
    > >
    > > > Vern Rabe wrote:
    > > > > Rick:
    > > > >
    > > > > By going to the Visual Basic Editor, Tools menu, References... menu,
    > > > > and adding a reference to the .mdb that has the function.
    > > >
    > > > I'm not certain that you don't still need to include the file name in

    > the call.
    > > >
    > > > --
    > > > Rick Brandt, Microsoft Access MVP
    > > > Email (as appropriate) to...
    > > > RBrandt at Hunter dot com
    > > >
    > > >
    > > >

    >
    >
    >
     
  11. Douglas J. Steele

    Douglas J. Steele
    Expand Collapse
    Guest

    As long as fnX doesn't exist in your local database and you've added a
    reference to the other database, fnx() should be sufficient to get it to
    run.

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no private e-mails, please)


    "Vern Rabe" <VernRabe@discussions.microsoft.com> wrote in message
    news:AF903DD9-7B90-423A-8657-D55F1E2D3308@microsoft.com...
    > Douglas:
    >
    > I tried that, and it worked. My local function executes "intVar =
    > FileName.ModName.fnX()". As a test, I then put a second action in the
    > AutoExec, this one a RunCode that directly calls the referenced function
    > (what I've been trying to do all along). On the assumption that the
    > actions
    > are executed synchronously, and since the first action includes a call to
    > the
    > referenced file, then when it comes time to run the second action, I'm
    > assuming the referenced file has to be fully loaded. When I start the
    > application with those in place I get the same
    > "...can't find the name..." error. Does this mean my syntax is incorrect?
    > Or
    > it simply won't work this way?
    >
    > I have hundreds of Access apps that need to have this code run on startup.
    > My hope is to go to each app, add a reference to my "shared" app, and add
    > a
    > RunCode action to the AutoExec macro. If that doesn't work, and I need to
    > implement something like your Douglas', I would go to each app, add a
    > reference to my "shared" app, add a module (most apps won't have one), add
    > a
    > function in this new module that calls the referenced app, and add a
    > RunCode
    > action to the AutoExec macro to run the new local function. Definitely
    > doable, but more work, and if direct autoexec of a referenced function
    > should
    > work, I'd rather get it to work. So... should I stop here and implement
    > this,
    > or does anyone have any other ideas?
    >
    > Thanks
    > Vern Rabe
    >
    >
    > "Douglas J. Steele" wrote:
    >
    >> Try creating a function in your local application that calls the function
    >> from the referenced application and call it from the AutoExec.
    >>
    >> That should indicate if it's trying to run too soon.
    >>
    >> --
    >> Doug Steele, Microsoft Access MVP
    >> http://I.Am/DougSteele
    >> (no e-mails, please!)
    >>
    >>
    >> "Vern Rabe" <VernRabe@discussions.microsoft.com> wrote in message
    >> news:6BD105F7-9126-40A9-8A9C-6195C4D7D270@microsoft.com...
    >> > Rick:
    >> >
    >> > When I go to design mode for the AutoExec macro, and select RunCode as
    >> > the
    >> > action, I am given a Function Name control to fill in. When I select
    >> > the
    >> > ellipsis in the control, it takes me to the Expression Builder window.

    >> There
    >> > I can select only local functions (functions in referenced applications

    >> are
    >> > not listed). If, back in the Function Name control, I explicitly type
    >> > in
    >> > "fnX()", it will run the local fnX function. If I instead type in
    >> > "=RefApp.fnX()", attempting to save will result in an error message
    >> > that
    >> > Access cannot parse it. By eliminating the equal sign, and typing in
    >> > "RefApp.fnX", the expression is parsed, but when I open the application
    >> > I

    >> get
    >> > an error that it can find the name "fnX". Could it be that Access is

    >> trying
    >> > to run the code before the referenced code has been retrieved?
    >> >
    >> > Thanks
    >> > Vern Rabe
    >> >
    >> >
    >> > "Rick Brandt" wrote:
    >> >
    >> > > Vern Rabe wrote:
    >> > > > Rick:
    >> > > >
    >> > > > By going to the Visual Basic Editor, Tools menu, References...
    >> > > > menu,
    >> > > > and adding a reference to the .mdb that has the function.
    >> > >
    >> > > I'm not certain that you don't still need to include the file name in

    >> the call.
    >> > >
    >> > > --
    >> > > Rick Brandt, Microsoft Access MVP
    >> > > Email (as appropriate) to...
    >> > > RBrandt at Hunter dot com
    >> > >
    >> > >
    >> > >

    >>
    >>
    >>
     

Share This Page