Solved

running a stored procedure and ability to monitor within Access?

Posted on 2011-09-12
7
229 Views
Last Modified: 2012-05-12
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
Comment
Question by:ironpen45
  • 4
  • 3
7 Comments
 
LVL 57
ID: 36524283
<< 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
 

Author Comment

by:ironpen45
ID: 36524920
<< 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
 
LVL 57
ID: 36525408
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:ironpen45
ID: 36536208
jim. can this code be an OnLoad property for my "ServerStatus" form, instead of having it opened from another?
0
 

Author Comment

by:ironpen45
ID: 36536217
or can i run the stored procedure with the dbRunAsync argument?
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 36536374
 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
 

Author Closing Comment

by:ironpen45
ID: 36588738
thanks JDettman. i used the dbRunAsync argument in a variation of the code and now works fine.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now