Is there a command that cause access to stop execution until the app it's called finish it's process. Below is the code that calls a batch file and in the last line of the batch file, it copies itself to a.txt. And then a wait must be given to allow the machine time to finish the copying before continuing to the next statement. This loop may be called anywhere from 1 to 20 times. Also, the data can be on the network and the processing time varies depending upon the import files and network traffic.
For i = 0 To gImportFileCount
If a(i, 0) Then
st = "test.bat " & j & ", " & a(i, 1) & ", " & a(i, 2) & ", " & a(i, 3)
Call Shell(gCamsDir & st, 0)
st = ""
While st = ""
st = Dir(gCamsDir & "a.txt"
Wend
If j = 1 Then j = 0
DelayEnd = DateAdd("s", 1, Now)
While DateDiff("s", Now, DelayEnd) > 0
Wend
Kill gCamsDir & "a.txt"
End If
Next i
For i = 0 To gImportFileCount
If a(i, 0) Then
st = "test.bat " & j & ", " & a(i, 1) & ", " & a(i, 2) & ", " & a(i, 3)
Call Shell(gCamsDir & st, 0)
st = ""
While st = ""
st = Dir(gCamsDir & "a.txt"
Wend
If j = 1 Then j = 0
DelayEnd = DateAdd("s", 1, Now)
While DateDiff("s", Now, DelayEnd) > 0
Wend
Kill gCamsDir & "a.txt"
End If
Next i