'Outputto isn't available now'

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

Getting an odd result.

Shelling FTP and, when it completes, sending an e-mail message (using
SendObject) that includes the results of a query.

If I do the Shell first and the SendObject second, the FTP works but I get
the SendObject failes with the message:

'Outputto' isn't available now.

If I swap the order - do the SendObject first, and the Shell() second, the
e-mail message is created okay, but the Shell appears to fail because the
FTP 'put' never happens.

'here's the FTP

strCommand = "FTP.exe -s:" & strFTPScriptFile & " >" &
strFTPLogFileName
lngPid = Shell(strCommand)

which equates to:

FTP.exe -s:tmpFTP.txt

There's some other code to build the components of the e-mail and then:

' here's the e-mail

DoCmd.SendObject acSendQuery, strQueryName, acFormatXLS,
strMailRecipients, , , _
"Daily Manager New Cash Summary", strMessage, False

Is there something fishy about the "shell" function? Does it set / verify a
a setting somehwere that would cause problems? I've also had problems with
doing multiple shell commands. It's like... if the first one works, the
second one doesn't. I can swap them.. and the one that originally failed
all of a sudden works.

So... which ever command is executed first will work. That appaers to be
the same thing that is happening here. It's kinda like an internal error
code or ??? is being set - enven if if the "shell" is successful - that
needs to be reset before doing the next activity.

Very odd.
 
Hi,
Not sure if this is your problem, but you should be aware that when you use
Shell in your code, your code continues to execute. It does not wait for the program
you shelled out to, to finish.
So if you have any code that depends on the results of your Shell, you must
use ShellAndWait.

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

Yes... I have API calls (WaitForSingleObject, etc) to suspend the process
until the Shell finishes. One difference is that I'm using VBA's "shell",
rather than the API "CreateProcessA", and passing the pid to "OpenProcess"
(I think... don't have the code handy) and then passing the handle to
WaitForSingleObject and, then CloseHandle.

Does VBA's "shell" do anything... funky... that might goof up SendObject
(that "CreateProcessA" would not)? And... what is it that SendObject is
examining that tells it that it can't run "at this time"?

This particular problem NEVER happens when running in debug. And... I can
occasionally get around it by moving the SendObject to a different code
module. But... if I do maintenance, the problem **may** start happening
again. In which case, I have to diddle around with new code modules until I
can find a combination that doesn't cause the error.

It's almost as though there is a single threaded connection (don't know what
to call it) of some sort that isn't being closed when shell (?) finishes?
Moving the routines around between different code modules almost seems to
suggest that the connection is associated with the code module? And that
moving the code around facilitates separate "connections"? I dunno. That's
speculation.

Oh different subject... from an earlier question. It there a way to
redirect output in the command that is executed by shell? That is... I'm
trying to log the results of FTP, as in:

ftp s:somefile > mylog.txt

The sommand works okay at the DOS prompt but does log when executed via
shell. Is there a way to get the redirect to work when run from shell?
 
Oops... need to edit messages a bit more completely.

Instead of writing:

"The sommand works okay at the DOS prompt but does log when executed via
shell. Is there a way to get the redirect to work when run from shell?"

I meant:

"The command works okay at the DOS prompt but does NOT log when executed via
shell. Is there a way to get the redirect to work when run from shell?"

Thanks.
 
Hi,
It's difficult to say withjout seeing your code.
All I can say is that I have successfully used Shell many times
without any timing problems (the fact that it works when stepping through
the code does suggest that it is a timing problem).
Redirection also works fine for me.
When shelling, I always go through the command interpeter using the /C
switch so that it closes as soon as the command has completed.
 
Back
Top