I have an Access 2003 database linked to an MS SQL 2005 backend. We use the database as part of a process whereby we use Zone OCR to scan records off paper forms into an XML file, suck the data off the XML file into a table and then present the data in the MS ACCESS db for manipulation and correction before being pushed back into other SQL tables. The Scanning process runs on a seperate instance of SQL so the only way to fire it from a Form object is through a SQL job. Unfortunately this will not return a timely recordset, meaning I get a notice that the job started, but that happens immediately and I don't know when the job ends, because the job runs on a named instance of SQL. I have figured out a method of firing a job off in the main instance of SQL to insert a single record into a logging table when the job completes. What I would like to do is use a Do Until loop, or some other method to look at this logging table (UCT_Count) and when the Count of records in the table is greater than 0, then pop a message box in Access stating the job is complete. I Have the following code to fire off the Job
This will fire the stored proc which starts a job etc...that ends with a single record in the logging table. I am just not sure how to wrap this in a Do Until loop until rCount >0
Then pop a MsgBox to show the job completed.
I hope this makes sense, if not let me know.
Code:
Function DataTransfer()
Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
Dim lngRecs As Long
Set cnn = New ADODB.Connection
Set cmd = New ADODB.Command
With cnn
.Provider = "SQLOLEDB"
.Properties("Data Source") = "ServerName"
.Properties("Initial Catalog") = "APEXDATA"
.Properties("User Id") = "XXXXuserName"
.Properties("Password") = "XXXXXXXXX"
.Open
End With
Set cmd.ActiveConnection = cnn
cmd.CommandText = "dbo.ACC_util_UCT_DataTransfer"
cmd.CommandType = adCmdStoredProc
cmd.Execute
Set cmd = Nothing
cnn.Close
Set cnn = Nothing
End Function
Code:
SELECT COUNT(CompleteDate) FROM UCT_Count as rCount
I hope this makes sense, if not let me know.
Comment