Solved

running a stored procedure and ability to monitor within Access?

Posted on 2011-09-12
7
230 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

821 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