1

I have set up a multithreading routine in Access which opens up several Access files at the same time and executes a specific function in each file. The files act in parallel. I would like to send Debug.Print messages to the main file which initiates the multithreading.

I'm not sure if it can do this or if there is a better solution.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Ian Cox
  • 85
  • 3
  • 12

2 Answers2

1

You have a number of processes, each working on their own part of the bigger picture.

The immediate pane of the "main" IDE belongs to that instance, in that process; you could Alt+Tab and then Alt+F11 to bring up a VBE instance in any/every instance to view that instance's Debug.Print output.

What you want is something like an ILogger implementation that writes the log entries in a dedicated database table: a DatabaseLogger, for example.

You replace Debug.Print with Logger.Log calls; that way you let the database server deal with the multiple incoming threads, and depending on the RDBMS you could even setup a job to cleanup, aggregate and/or archive the older log records. Or whatever, as long as it's not logic I need to care about in VBA code.

Writing to another VBE's immediate toolwindow involves low-level, cross-process Win32 wizardry that doesn't need to clutter up an otherwise nice & tidy VBA project. I wouldn't bother with that, there are simpler solutions.

Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235
  • Hi Mat,logging is something that I had been considering. I will check the code out and see how it fits. thanks so much. – Ian Cox Aug 26 '17 at 08:36
  • Hi Mat, those links are amazing. I was checking out the dictionary you created and then the updated dictionary. there is a reference to in {Private Type tDictionary Encapsulated As List }. should this also be "TYPE TypeValidator" or is it another class. – Ian Cox Aug 28 '17 at 13:40
0

You could create a PublicNotCreatable UserForm (not an Access Form) in the main application, and pass a reference to it, to all of the parallel apps. Add a custom method to the UserForm, like 'PrintLine(message as string), and each app can callform.PrintLine("app is running")`?

You could then have the UserForm display the output, or possibly, have the UserForm output the message to the Immediate window of the main application.

ThunderFrame
  • 9,352
  • 2
  • 29
  • 60