• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 237
  • Last Modified:

running a stored procedure and ability to monitor within Access?

i have an MDB front end which is supposed to run stored procedures off a SQL server on the same box.

the sp's are triggered manually by the end-user with via a form. no problems there.

however, i would also like to open another form which monitors the progress of the sp's. unfortunately, the MDB system is busy (hourglass) and will not update the monitor form (through the OnTimer property)

so unless there is another way to run sp's instead of a pass through query (or ADO recordset) i can't think of another way to separate the query process from the monitor form self updates.

i thought of calling the passthrough query which would be housed in another MDB file. any thoughts? thanks!
0
ironpen45
Asked:
ironpen45
  • 4
  • 3
1 Solution
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
<< any thoughts?>>

 Have the SP write out updates to a log table, either as a series of records or update of a single status message field.

 Then in Access, have a form bound to that table.

Jim.
0
 
ironpen45Author Commented:
<< Have the SP write out updates to a log table, either as a series of records or update of a single status message field.>>

actually, the monitor form shows data from an attached SQL table, which is updated by the SP you're talking about.

the problem, again, is that the form doesn't get updated until the passthrough query is completed. i need the monitor form to update while the process is on-going.
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
In DAO, you can do something like this:

    sParam = sParam & "?"
    sql = "{?=call qrySoTransPost (" & sParam & ")}"
    Set conPost = GetSQLConnection()
    Set qdf = conPost.CreateQueryDef("", sql)
    qdf.ODBCTimeout = 0
    With qdf
         .Parameters(0).Direction = dbParamReturnValue
         .Parameters("@UserID") = GetCurrentUser()
       
        DoCmd.OpenForm "ServerStatus", "Post", 1000
         .Execute dbRunAsync
         While .StillExecuting
             DoEvents
         Wend
         If .Parameters(0) <> 0 Then
            DoCmd.Hourglass False
            MsgBox "Post failed@@" & .Parameters(0)
            .Close
            conPost.Close
         DoCmd.Close acForm,  "ServerStatus", " Post"
            Exit Sub
         End If
         DoCmd.Close acForm,  "ServerStatus", " Post"
         .Close
    End With

 Key being to specify the dbRunAsync argument.

Jim.
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
ironpen45Author Commented:
jim. can this code be an OnLoad property for my "ServerStatus" form, instead of having it opened from another?
0
 
ironpen45Author Commented:
or can i run the stored procedure with the dbRunAsync argument?
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
 Not sure I understand the question.  You need to use the dbRunAsync argument in order for VBA to continue execution once you called the stored proc.

  Beyond that, how you manage the status messaging is up to you.  In the above, that was done with a status form.  The status form was bound to a logging table, which would be cleared by the status form when it was opened.

  The SP then would write to the logging table as it processed.

  When it was done (.StillExecuting = False), the status form would be closed.

Jim.
0
 
ironpen45Author Commented:
thanks JDettman. i used the dbRunAsync argument in a variation of the code and now works fine.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now