calling an exe from access macro
> I have written a simple c program which reads some data from a text file
> writes back into another text file. Then I used build all in the vc++ and
> created a .exe and bunch of other files along with a folder called
> 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
> an error saying
> 'Debug Assertion Failed'
> FIle: fscanf.c
> Line : 54.
> But when I double click on the .exe file from windows explorer, it runs
> and it also runs fine from the command prompt. Is there anything I need
> do in the vc++ environment or MS Access environment to make this run
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.
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
Standard disclaimers etc. No spam please.