By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,841 Members | 1,704 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,841 IT Pros & Developers. It's quick & easy.

Halt execution at Shell command

P: n/a
Hey,

I'm trying to automate an import routine by using the shell command to
call a batch file that will run a vendor export utility before
continuing with the import. The problem is that execution seems to
want to continue past the shell command once the export routine is
launched, which hoses the import. What's the proper method of halting
execution until the batch file finishes?

Here's my code:

Private Sub cmdImport_Click()
Dim strSQL As String, strDocName As String
Dim strLinkCriteria As String, Config As DAO.Recordset
Dim RetVal, fs As Object

Set Config = CurrentDb.OpenRecordset("Config")
Set fs = CreateObject("Scripting.FileSystemObject")

RetVal = Shell(Config!RootDir & "DoExport.Bat",vbNormalFocus)
DoCmd.SetWarnings (False)
strSQL = "DELETE Import.* FROM Import;"
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings (True)

If Not fs.FileExists(Config!ImportFile) Then
MsgBox "No new records for import."
Exit Sub
End If
specs = "ImportInserts"
table = "Import"
file = Config!ImportFile
DoCmd.TransferText acImportDelim, specs, table, file
End Sub

Thanks,
Nov 30 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

G. Miller wrote:
Hey,

I'm trying to automate an import routine by using the shell command to
call a batch file that will run a vendor export utility before
continuing with the import. The problem is that execution seems to
want to continue past the shell command once the export routine is
launched, which hoses the import. What's the proper method of halting
execution until the batch file finishes?

Here's my code:

Private Sub cmdImport_Click()
Dim strSQL As String, strDocName As String
Dim strLinkCriteria As String, Config As DAO.Recordset
Dim RetVal, fs As Object

Set Config = CurrentDb.OpenRecordset("Config")
Set fs = CreateObject("Scripting.FileSystemObject")

RetVal = Shell(Config!RootDir & "DoExport.Bat",vbNormalFocus)
DoCmd.SetWarnings (False)
strSQL = "DELETE Import.* FROM Import;"
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings (True)

If Not fs.FileExists(Config!ImportFile) Then
MsgBox "No new records for import."
Exit Sub
End If
specs = "ImportInserts"
table = "Import"
file = Config!ImportFile
DoCmd.TransferText acImportDelim, specs, table, file
End Sub

Thanks,
If I were you, I'd have a look at VBNet... I think it answers your
question. here:
http://vbnet.mvps.org/code/faq/getexitcprocess.htm

Nov 30 '06 #2

P: n/a
G. Miller wrote:
Hey,

I'm trying to automate an import routine by using the shell command to
call a batch file that will run a vendor export utility before
continuing with the import. The problem is that execution seems to
want to continue past the shell command once the export routine is
launched, which hoses the import. What's the proper method of halting
execution until the batch file finishes?
This is a common problem, posted here often.

The most commonly used solution is the code here:

http://www.mvps.org/access/api/api0004.htm

--
'---------------
'John Mishefske
'---------------
Dec 1 '06 #3

P: n/a


Private Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long

pass in -1& as the milliseconds value for an infinate
wait-till-finished
G. Miller wrote:
Hey,

I'm trying to automate an import routine by using the shell command to
call a batch file that will run a vendor export utility before
continuing with the import. The problem is that execution seems to
want to continue past the shell command once the export routine is
launched, which hoses the import. What's the proper method of halting
execution until the batch file finishes?

Here's my code:

Private Sub cmdImport_Click()
Dim strSQL As String, strDocName As String
Dim strLinkCriteria As String, Config As DAO.Recordset
Dim RetVal, fs As Object

Set Config = CurrentDb.OpenRecordset("Config")
Set fs = CreateObject("Scripting.FileSystemObject")

RetVal = Shell(Config!RootDir & "DoExport.Bat",vbNormalFocus)
DoCmd.SetWarnings (False)
strSQL = "DELETE Import.* FROM Import;"
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings (True)

If Not fs.FileExists(Config!ImportFile) Then
MsgBox "No new records for import."
Exit Sub
End If
specs = "ImportInserts"
table = "Import"
file = Config!ImportFile
DoCmd.TransferText acImportDelim, specs, table, file
End Sub

Thanks,
Dec 1 '06 #4

P: n/a
On Fri, 01 Dec 2006 06:16:44 GMT, John Mishefske
<jm**********@SPAMyahoo.comwrote:
>G. Miller wrote:
>Hey,

I'm trying to automate an import routine by using the shell command to
call a batch file that will run a vendor export utility before
continuing with the import. The problem is that execution seems to
want to continue past the shell command once the export routine is
launched, which hoses the import. What's the proper method of halting
execution until the batch file finishes?

This is a common problem, posted here often.

The most commonly used solution is the code here:

http://www.mvps.org/access/api/api0004.htm

--
'---------------
'John Mishefske
'---------------

Thanks for the link. Worked great.
Dec 4 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.