How to get the shell function to run in a non asynchronous manner.

E

ericg

I call a "C" program from within Microsoft Access. The "C" program modifies a
file that Access needs to process, but Access tears right off without waiting
for the "C" executable to complete. Is there a way to use the "shell" command
NON-asynchronously.
 
D

Dirk Goldgar

ericg said:
I call a "C" program from within Microsoft Access. The "C" program
modifies a file that Access needs to process, but Access tears right
off without waiting for the "C" executable to complete. Is there a
way to use the "shell" command NON-asynchronously.

See if this article on the Access Web does the trick for you:

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

Belinda

I have gone and read the code posted inn:
http://www.mvps.org/access/api/api0004.htm

But unfortunately, I am too green to understand full usage. Can you please
answer some questions?
Do I need to name this module? and if so, what name do I give it. And
where he says to call shell I have already this code (see below ----). How
do I integrate both?


----
Private Sub cmdImportRKEM_Click()
On Error GoTo Err_cmdImportRKEM_Click

Dim stAppName As String

stAppName = "C:\GOV\MLTRKEM.BAT"
Call Shell(stAppName, 1)

Exit_cmdImportRKEM_Click:
Exit Sub

Err_cmdImportRKEM_Click:
MsgBox Err.Description
Resume Exit_cmdImportRKEM_Click

End Sub
-----



Brian said:
Is there a way to force Shell synchronously so that it waits for the
task to complete before working its way down to the next line of code?

If not, can I track the status of the task ID returned by the shell
to find out if it is closed before proceeding to the next step in my
code?

Try the code posted here:

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

Douglas J. Steele

Copy all of the code from that page into a new module and save the module.
You can call it anything you want: just make sure you give the module a
unique name (it cannot have the same name as a function or sub).

Change your existing code from

Call Shell(stAppName, 1)

to

Call ShellWait(stAppName, 1)
 
B

Belinda

You're the best! It worked like a charm--I'm soooo happy!
Thank You Thank You Thank You!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top