Results 1 to 3 of 3

Thread: Calling SQL Server Stored Procedure

  1. #1
    Join Date
    Aug 2003
    Location
    Bellville, TX
    Posts
    3

    Calling SQL Server Stored Procedure

    I need to be able to call a SQL Server stored procedure and have it execute and return control back to the Access program before the SP completes. I am using ADO to do the call to the SP. How can I get Access to continue on with it's code execution and not wait on the stored procedure to complete?

  2. #2
    Join Date
    May 2006
    Posts
    407
    I don't know very much about the interface between Access and SQL to be able to know if there is a way within Access to do this. I do know of a work-around. What I would do is create another Access database which I would open using the Shell command because Access does not wait for anything when you do a Shell command. So, using the Shell command, you can pass parameters to the new instance of Access telling it which database to open and you can even pass the database parameters. In the parameters you can specify which SP to run, etc. In the other database, you can just have it quit when the SP is finished.
    Here is the code I use to open another Access database:
    Code:
    Dim RetVal as Variant
      RetVal = Shell("""" & SysCmd(acSysCmdAccessDir) & _
         "MSACCESS.EXE""  " & _ 
         "g:\apps\JobRecords\RefreshDB.mdb" & " /cmd """ & _
         CurrentDb().Name & """", vbNormalFocus)
    The "/cmd" tells Access to look at what follows as the parameters to pass into the database being opened. Within Access you can retrieve this parameter via the Command function. My Access VBA help says that Command is not available in Microsoft Office applications. But it IS available in VBA, which I did not see in the help file, but trust me, it is available, I'm using it.
    How I'm using it in the sample I gave you, is that I'm calling another Access database, RefreshDB.mdb, and then doing an Application.Quit in the calling from database. The new database will then delete the calling from database and copy the updated (previously by me, not in this code) database into the production location. This called database (RefreshDB.mdb) will close itself, but just before closing, will do a Shell command itself and open the newly copied version of the actual production database.
    Hope that is clear enough to follow and that this will help.
    Vic

  3. #3
    Join Date
    Aug 2003
    Location
    Bellville, TX
    Posts
    3
    Unfortunately, in the environment I am in, that will not work. I am looking into the out of process call from ADO.

Posting Permissions

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