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 -
-
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
-
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 - SELECT COUNT(CompleteDate) FROM UCT_Count as rCount
Then pop a MsgBox to show the job completed.
I hope this makes sense, if not let me know.
4 2414 NeoPa 32,568
Recognized Expert Moderator MVP
Would something like this work for you : - Do
-
DoEvents()
-
rCount = DCount("[CompleteDate]", "[UCT_Count]")
-
Loop Until rCount > 0
Thanks, that did the trick - had to play around with placement to get it to keep from interrupting my code execution, but it works like a charm now. Much better alternative to a generic sleep timer that I was going to use. Thanks again. Completed code posted below: -
Function DataTransfer()
-
-
Dim cnn As ADODB.Connection
-
Dim cmd As ADODB.Command
-
Dim lngRecs As Long
-
Dim rCount As Integer
-
-
rCount = 0
-
-
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") = "XXXXuser"
-
.Properties("Password") = "XXXXXX"
-
.Open
-
End With
-
-
Set cmd.ActiveConnection = cnn
-
cmd.CommandText = "dbo.ACC_util_UCT_DataTransfer"
-
cmd.CommandType = adCmdStoredProc
-
-
cmd.Execute
-
-
Do
-
DoEvents
-
rCount = DCount("[CompleteDate]", "[dbo_UCT_Count]")
-
Loop Until rCount > 0
-
MsgBox "The Data has been transfered."
-
-
-
Set cmd = Nothing
-
cnn.Close
-
Set cnn = Nothing
-
End Function
-
ADezii 8,834
Recognized Expert Expert
If you wish to avoid a Do..Loop all together: - Create a small Form and Minimize it.
- Set the Form's Timer Interval to 10000 (10 secs).
- Place the following code, or something similar, in the Form's Timer() Event.
-
Private Sub Form_Timer()
-
Dim intResponse As Integer
-
Dim strMsg As String
-
-
strMsg = "Record Count in Table UCT_Count > 0" & vbCrLf & vbCrLf & _
-
"Reset/Minimize Form and Set Timer Interval?"
-
-
If DCount("*", "UCT_Count") > 0 Then
-
DoCmd.Restore
-
Me.TimerInterval = 0 'Turn OFF the Timer
-
intResponse = MsgBox(strMsg, vbYesNo + vbQuestion, "Reset Form")
-
If intResponse = vbYes Then
-
DoCmd.Minimize
-
Me.TimerInterval = 10000 'Restore Timer Interval to 10 secs
-
End If
-
End If
-
End Sub
-
- Every 10 seconds (you can vary this), Table UDC_Count will be polled to see if it contains a Record. If it does, the Form will be Restored with some kind of descriptive Message or a Message Box, and the Timer will be Disabled. You will then have the option to Rest the Timer, Minimize the Form again, and start all over.
NeoPa 32,568
Recognized Expert Moderator MVP
While my suggestion answers your question more directly, I would certainly recommend ADezii's suggestion over that as it uses the facilities of Access better.
Note also the slight change to the DCount() usage. Your original call requests the count of all records which contain a value for [CompleteDate]. If you really need a simple count of all records, then ADezii's version is the more correct. Even if there will always be a value for any existing record, his code is clear what it's asking for whereas yours (in that situation) would return an accurate value, but be misleading for anyone reading your code.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: The Beast |
last post by:
I'm trying to create a thread to write to the serial port and I keep
getting an odd error
cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned
long (__stdcall *)(void *)'
and it points to the CreateThread call. Here is my class, why is it
doing this and how can I fix it?
<TxdRxd.h>
|
by: - |
last post by:
i have a query as follows and is unsure whether it is mysql or php:
$result = mysqli_query("SELECT COUNT(*) > @foobar AS status ....") where
it's suppose to get a one row value of either '0' or '1' (false or true)
if i were to do a SELECT COUNT(*) FROM...
i can use the php $row to refer to the index.
if i were to do a SELECT COUNT(*) AS status FROM...
i can use the php $row to refer to the index.
|
by: Peter Kirk |
last post by:
Hi there
I am looking at using a thread-pool, for example one written by Jon Skeet
(http://www.yoda.arachsys.com/csharp/miscutil/). Can anyone tell me if this
pool provides the possibility to wait for all its threads to finish?
For example, if I start 20 threads:
CustomThreadPool pool = new CustomThreadPool("PetersThreadPool");
ThreadMethod m = new ThreadMethod(InsertThread);
|
by: Farel |
last post by:
Which is Faster in Python and Why?
jc = {}; m =
x = ,,.......] # upwards of 10000 entries
def mcountb():
for item in x:
b = item; b.sort(); bc = 0
for bitem in b: bc += int(bitem)
try: m = jc
|
by: cwho.work |
last post by:
Hi!
We are using apache ibatis with our MySQL 5.0 database (using innodb
tables), in our web application running on Tomcat 5. Recently we
started getting a number of errors relating to
java.sql.SQLException: Deadlock found when trying to get lock; Try
restarting transaction message from server: "Lock wait timeout
exceeded; try restarting transaction";
We get such errors generally on inserts or updates while applying a
| |
by: Jimmy |
last post by:
Is there a way to force access to wait a specified time before making a
calculation?
On my report there is a subreport with a number of calculation on it. One if
which is a count of certain records using a text control with a running sum.
When I display the subreport on my main report, I can see the correct count
but when I make a reference to that control on the main report, I simply get
the number 1. I am sure that the reference to the...
|
by: Deepak |
last post by:
I am programing a ping application which pings various centers . I
used timer loop and it pings one by one.
Now when i finish pinging one center it should wait for the
ping_completed function to be executed and then continue pinging
another certer.
The ping_completed function is called on completion of ping by the os
and i have no control on it .
|
by: Ping |
last post by:
Hi,
I'm wondering if it is useful to extend the count() method of a list
to accept a callable object? What it does should be quite intuitive:
count the number of items that the callable returns True or anything
logically equivalent (non-empty sequence, non-zero number, etc).
This would return the same result as len(filter(a_callable, a_list)),
but without constructing an intermediate list which is thrown away
after len() is done.
|
by: Jason Zheng |
last post by:
This may be a silly question but is possible for os.wait() to lose track
of child processes? I'm running Python 2.4.4 on Linux kernel 2.6.20
(i686), gcc4.1.1, and glibc-2.5.
Here's what happened in my situation. I first created a few child
processes with Popen, then in a while(True) loop wait on any of the
child process to exit, then restart a child process:
import os
from subprocess import Popen
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |