calling an exe from access macro 
Author Message
 calling an exe from access macro

Hi All,

I worte this very simple program and am trying to call the exe from MS
Access in a macro. it gives some error saying it cannot exexcute fscanf. The
progrm runs from the command line prompt and gives no errors. Could any one
please explain why this happens and what i can do to run the program
properly?

Please give me any suggestions you have...

Thanks.

Elango.



Sun, 27 Oct 2002 03:00:00 GMT  
 calling an exe from access macro


Quote:
> I worte this very simple program and am trying to call the exe from MS
> Access in a macro. it gives some error saying it cannot exexcute
> fscanf. The
> progrm runs from the command line prompt and gives no errors.
> Could any one
> please explain why this happens and what i can do to run the program
> properly?

You need to give a bit more context.  For example,
what is the full exact error message?  What is the
line of code that calls the executable?  Otherwise,
it's just flailing around in the dark trying to
guess why an fscanf might fail.

For example: it might fail because the file was
not properly opened when you ran it from Access.
And that might happen because you had a different
default path during the Access session.

But without some more context, this is a very
wild guess indeed.

--
Dan Evens
Standard disclaimers etc. No spam please.



Sun, 27 Oct 2002 03:00:00 GMT  
 calling an exe from access macro
Hey Dan,

Thanks for your reply.

I have written a simple c program which reads some data from a text file and
writes back into another text file. Then I used build all in the vc++ and it
created a .exe and bunch of other files along with a folder called 'debug'.
Now want to call this .exe file from a MS Access Macro using the command
called 'RunApp' and specify the file which is in the same folder as the
Access Database. It starts running and then takes in the input and the gives
an error saying

'Debug Assertion Failed'

C:\...\debug\prog.exe
FIle: fscanf.c
Line : 54.

But when I double click on the .exe file from windows explorer, it runs fine
and it also runs fine from the command prompt. Is there anything I need to
do in the vc++ environment or MS Access environment to make this run without
error??

Thanks for all your help.

Cheer!
Elango.

Quote:

> You need to give a bit more context.  For example,
> what is the full exact error message?  What is the
> line of code that calls the executable?  Otherwise,
> it's just flailing around in the dark trying to
> guess why an fscanf might fail.

> For example: it might fail because the file was
> not properly opened when you ran it from Access.
> And that might happen because you had a different
> default path during the Access session.

> But without some more context, this is a very
> wild guess indeed.

> --
> Dan Evens
> Standard disclaimers etc. No spam please.



Sun, 27 Oct 2002 03:00:00 GMT  
 calling an exe from access macro


Quote:
> I have written a simple c program which reads some data from a text file
and
> writes back into another text file. Then I used build all in the vc++ and
it
> created a .exe and bunch of other files along with a folder called
'debug'.
> Now want to call this .exe file from a MS Access Macro using the command
> called 'RunApp' and specify the file which is in the same folder as the
> Access Database. It starts running and then takes in the input and the
gives
> an error saying

> 'Debug Assertion Failed'

> C:\...\debug\prog.exe
> FIle: fscanf.c
> Line : 54.

> But when I double click on the .exe file from windows explorer, it runs
fine
> and it also runs fine from the command prompt. Is there anything I need
to
> do in the vc++ environment or MS Access environment to make this run
without
> error??

Presumably this means you open a file someplace before you
call fscanf. Do you check that the file is opened properly?
The debug assertion probably indicates that the file handle
is not valid.

If I recall, you have something like

FILE *fpDataFile = fopen("filename.ext");

and if the file fails to open, fpDataFile is NULL.  Check
the help files on fopen (or whatever you actually used
to open the file).

The thing is, just because the exe is in the same dir as
the file it is supposed to open, it does *NOT* mean that
that file is on the path.

See, if you go to that dir and run the program from there,
the default dir is *that* dir.  But if you run the prog
from Access, then the default dir is whatever Access has
set its default dir to be.

Try this:
Step one:  From your access session, find out what its default
working directory is.  I *think* you can do this by simply
going to File | Open, and seeing what dir it looks in by
default.  I'm *guessing* this is going to be different from
the dir containing the file to be opened. (I'm not a big
Access user. If this is wrong, could somebody please say?)

Step two:  In the Visual C/C++ environment, open your project
that you used to make the executable. Under the Debug project
settings, set the working directory to the same dir.  Also,
set any other things like command line that may need to be
set to simulate running.

Step three:  Run your program in debug mode by pressing <F5>
in the Visual C session.  You can set a breakpoint just
before the fscanf call that fails.  Check that the file
handle is a valid open file.

Step four: Let the debug session go through the fscanf call
and see if it still asserts. If it does, you should be able
to see exactly what it thinks is wrong.  The assert macro
fires when its argument is zero.

An alternative test: From a DOS console prompt, make the
default dir something besides the dir with the exe and
the data file.  From *that* directory, type the full path
name of the executable and see if it runs from there.

The solution may be to include the full path name of the
data file, including drive and dir, not just the name
and extension.

--
Dan Evens
Standard disclaimers etc. No spam please.



Sun, 27 Oct 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Calling an exe from MS Access Macro

2. How can I call a Access-Macro using DAO and VC++

3. calling access macro

4. How to call B.exe from A.exe and then stop A.exe

5. UID keeps changing in call to OpenEx when accessing secure Access DB

6. DevStudio Macro Terminator: msdev.exe - Application Error

7. Call C++ MACRO from C# ?

8. #ifdef in macro call

9. Calling multiple functions in a macro.

10. cancelling function call with macro

11. Calling a Macro ???????

12. EXCEL MACRO call COM method

 

 
Powered by phpBB® Forum Software