RetVal problem

R

Ray

I am trying to call a batch file from a command button in an access form.

My VBA is:

Dim RetVal
RetVal = Shell("C:\Member Management 4\mm4backup.bat", 1)

This was not working so I put a PAUSE in the batch file to see what was
going on.

The batch file works correctly when directly executed from within its home
folder and the batch header looks like this:

C:\Member Management 4\Pause

When I try to run it from the command button it does not shell to the
correct folder but instead the batch file header shows as

C:\Documents and Settings\Ray|My Documents\Pause

How do I fix this?

Any help gratefully appreciated.
 
J

Jack Leach

You can try enclosing the path with its own set of quotes:
RetVal = Shell("""C:\Member Management 4\mm4backup.bat""", 1)


You can try the ShellExecute API found here
http://www.mvps.org/access/api/api0018.htm

For some reason I switched from Shell to the API, though I don't remember
the reason, or how the two are different.

Is there any particular reason you need to evaluate the return? I would
generally run it as:

Shell "C:\Folder\File.bat"

These are all shots in the dark, but something might help.
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
R

Ray

I did try the dbl quotes but just got a sysntax error.

Will try theAPI.

I am only evaluating the return to see why it does not work. Once I get it
working I will remove the pause.

Ray
 

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