[DB ACCESS] Module and batch file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • viki1967
    Contributor
    • Oct 2007
    • 263

    [DB ACCESS] Module and batch file

    Hi all.

    I have this module in the DB ACCESS.

    Code:
    Function estrai()
    Dim dbs As Database
    Set dbs = CurrentDb
    
        g_HostSettleTime = 15
            Dim Sessions As Object
        Dim System As Object
        Set System = CreateObject("EX.System")   
        If (System Is Nothing) Then
            MsgBox "Errore."
            Stop
        End If
        Set Sessions = System.Sessions
    
        If (Sessions Is Nothing) Then
            MsgBox "Errore."
            Stop
        End If
            
            Dim sess0 As Object
            Set sess0 = System.ActiveSession
            If (sess0 Is Nothing) Then GoTo init
            System.Quit
            
    init:
            Shell ("c:\programmi\ex\session.exe")
    
    ...
    
        Application.Quit
    End Function
    and I write this batch file:

    Code:
    @echo off
    
    "C:\Programmi\Microsoft Office\OFFICE11\msaccess.exe" 
    "D:\Inetpub\wwwroot\mdb-database\database.mdb"
    /cmd Estrai()
    The idea is open the DB Access and start the function Estrai() with the batch file.

    No error but the function Estrai() not start, why?

    Can you help me?
    kind regards
    viki
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    1. Create a Macro, let's say mcrExecuteFunct ion for simplicity.
      • Set the Action Column of the Macro = RunCode
      • Set the Function Name = Estrai()
      • Make sure the Function is Declared as Public in a Standard Code module
    2. Create the Batch File as follows:
      Code:
      @echo off 
      cls
      "C:\Programmi\Microsoft Office\OFFICE11\msaccess.exe"  _
      "D:\Inetpub\wwwroot\mdb-database\database.mdb"  _
      /x mcrExecuteFunction
    3. Now, when you Run the Batch File, Access will Open Database.mdb, and Execute the Macro mcrExecuteFunct ion (/x mcrExecuteFunct ion), which in turn will Execute the Estrai() Function

    Comment

    • viki1967
      Contributor
      • Oct 2007
      • 263

      #3
      Many thanks x your answer.

      Your method working but I have one alert window in the connection.

      If I continue the macro working.

      I'ts possible in the file batch erase or ignore all alert ?

      kind regards

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by viki1967
        Many thanks x your answer.

        Your method working but I have one alert window in the connection.

        If I continue the macro working.

        I'ts possible in the file batch erase or ignore all alert ?

        kind regards
        Sorry, but you will have to be much more specific.

        Comment

        Working...