Simple command line prompt to call MS Access Module?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tonytony24@gmail.com

    Simple command line prompt to call MS Access Module?

    Hi All:

    I was wondering if there's a simple way to call a MS Access Module
    through either
    Command Prompt
    MS Script
    any other way...

    Thanks for the response.

    I am trying to extract some data out of a table in Access on a
    scheduled basis, I figured the simplest way is to do a simple module,
    have some command to extract the information, then schedule it.

    thx again
    tony

  • Wayne Morgan

    #2
    Re: Simple command line prompt to call MS Access Module?

    Yes, sort of.

    You can call a macro in the command line when you open Access. The macro
    could have the RunCode command which will run a VBA function.

    Example:
    "<path>\msacces s.exe" "<path>\MyDatab ase.mdb" /x MacroName

    You can also use an AutoExec macro to automatically run code when you open
    the database or place code in the Open event of your startup form to run the
    procedures you need.

    Another option is to use the /cmd switch on the command line. You can then
    use the Command() function in code to extract this information to react as
    desired.

    --
    Wayne Morgan
    MS Access MVP


    <tonytony24@gma il.com> wrote in message
    news:1143129326 .369651.205910@ i39g2000cwa.goo glegroups.com.. .[color=blue]
    > Hi All:
    >
    > I was wondering if there's a simple way to call a MS Access Module
    > through either
    > Command Prompt
    > MS Script
    > any other way...
    >
    > Thanks for the response.
    >
    > I am trying to extract some data out of a table in Access on a
    > scheduled basis, I figured the simplest way is to do a simple module,
    > have some command to extract the information, then schedule it.
    >
    > thx again
    > tony
    >[/color]


    Comment

    • Anthony England

      #3
      Re: Simple command line prompt to call MS Access Module?

      <tonytony24@gma il.com> wrote in message
      news:1143129326 .369651.205910@ i39g2000cwa.goo glegroups.com.. .[color=blue]
      > Hi All:
      >
      > I was wondering if there's a simple way to call a MS Access Module
      > through either
      > Command Prompt
      > MS Script
      > any other way...
      >
      > Thanks for the response.
      >
      > I am trying to extract some data out of a table in Access on a
      > scheduled basis, I figured the simplest way is to do a simple module,
      > have some command to extract the information, then schedule it.
      >
      > thx again
      > tony[/color]


      If the machine which is going to run the scheduled task has Access on it,
      then you could call something like this:

      "C:\Program Files\Microsoft Office\Office10 \MSACCESS.EXE"
      "C:\MyExtractor .mdb" /cmd "DoExtract"

      The database MyExtractor.mdb has all of the functions in a module together
      with an AutoExec macro. The macro has a single step of RunCode where the
      function is =DoExtract()

      Public Function DoExtract()

      Dim strCommand As String

      strCommand = Command()

      If StrComp(strComm and, "DoExtract" , vbBinaryCompare ) = 0 Then
      ' Code to do the extract
      Else
      ' Wrong start code - so quit
      Application.Qui t
      End If

      End Function


      The code could do whatever extraction was needed and then shut itself down.
      The disadvantage of this is you need Access installed (and scheduled tasks
      are often run from a server where this is not the case) and also the fact
      that Access is a big program to start if all you need to do is extract a bit
      of data.
      You could create a vbs file which does it all without needing Access at all.
      This has the advantage that you only need notepad to write it, but VBScript
      suffers from being weakly-typed and offers quite limited error handling.
      However, if you wrote it carefully, you would be OK. If you wanted the
      advantage of a small program loading together with error handling you would
      need something like Visual Basic to create an exe file.




      Comment

      Working...