If the scenario runs properly when invoked from the Add-in wizard, but fails programmatically, there is usually a problem with how the Total Access Statistics database is loaded as a library.
Make sure the runtime library of Total Access Statistics is loaded as a library reference. This is set from a module under the Tools, References menu.
Read the manual chapter or refer to the help file's section on Advanced Topics for details on running Total Access Statistics programmatically. See the SAMPLE database included with the program for examples.