Module not calling a function

prasadgov

Member
Local time
Today, 16:48
Joined
Oct 12, 2021
Messages
120
Hi All,

I have an Access db, which has few modules. One of the module, Load Source Tables executes or calls other functions within such as, running the WinSCP and another function to imports those downloaded files from one of the folders, which is in the same directory as the WinSCP exe.
I have a macro called mcrFullRun, which runs other macros such as, macros to clear tables, load source tables, compile and finally export the output as Excel.
The macros run well except for the Load Source macro mcrLoadSourceTable, which calls the module, Load Source Tables. Only the WinSCP function runs and downloads the file but the import function does not execute.
But when I run the specific macro, mcrLoadSourceTable separately, it runs everything including the Import functions.
Why does it fail in the mcrFullRun?

I need to schedule this as a job by running a batch job from Windows Task scheduler, which opens the DB and executes the mcrFullRun but because of the issue, I am running it manually.

Any Pointers?

TIA
 
Not aware you can have spaces in module names? :(
 
The macros run well except for the Load Source macro mcrLoadSourceTable, which calls the module, Load Source Tables. Only the WinSCP function runs and downloads the file but the import function does not execute.
But when I run the specific macro, mcrLoadSourceTable separately, it runs everything including the Import functions.
Why does it fail in the mcrFullRun?

It is going to have to be something that is set up in mcrFullRun that messes up your context, because according to the references I checked, a macro definitely CAN call / activate another macro.
 
You cannot execute a module. You can only execute subs and functions. You also cannot have a module with the same name as a sub or function. But that should raise a compile error and I presume you have no compile errors.

I don't ever use macros because
1. they are difficult to write
2. they are difficult to read
3. they are impossible to document
4. I think they have some debugging facility now but they didn't use to.

So, If there is any debugging tool for macros, use it to follow the execution of the macro so you can see why one procedure is being skipped.

Better still, convert all the macros to code. Then create one function that is the top of the execution stream and have your one macro run that function. Then you can work entirely with VBA which is easy to write and read and document and which has debugging tools.
 
Hi All,

I have an Access db, which has few modules. One of the module, Load Source Tables executes or calls other functions within such as, running the WinSCP and another function to imports those downloaded files from one of the folders, which is in the same directory as the WinSCP exe.
I have a macro called mcrFullRun, which runs other macros such as, macros to clear tables, load source tables, compile and finally export the output as Excel.
The macros run well except for the Load Source macro mcrLoadSourceTable, which calls the module, Load Source Tables. Only the WinSCP function runs and downloads the file but the import function does not execute.
But when I run the specific macro, mcrLoadSourceTable separately, it runs everything including the Import functions.
Why does it fail in the mcrFullRun?

I need to schedule this as a job by running a batch job from Windows Task scheduler, which opens the DB and executes the mcrFullRun but because of the issue, I am running it manually.

Any Pointers?

TIA
You should skip macros entirely and switch to an all-vba result,
Then, you could take advantage of this current advice which I would normally give people in your situation:

Do a debugger F8 and go line by line to see when and where what is being called.
 
You cannot execute a module. You can only execute subs and functions. You also cannot have a module with the same name as a sub or function. But that should raise a compile error and I presume you have no compile errors.

I don't ever use macros because
1. they are difficult to write
2. they are difficult to read
3. they are impossible to document
4. I think they have some debugging facility now but they didn't use to.

So, If there is any debugging tool for macros, use it to follow the execution of the macro so you can see why one procedure is being skipped.

Better still, convert all the macros to code. Then create one function that is the top of the execution stream and have your one macro run that function. Then you can work entirely with VBA which is easy to write and read and document and which has debugging tools.
You can execute macros step by step I seem to recall,
 
you can add a comment
1723065638212.png


but still very limiting
 

Users who are viewing this thread

Back
Top Bottom