I have a code with a recursive function that checks into a folder for folders and writes the name, ID, and depth of the folder in my database. The process is repeated until all folders are in the database (usually 200 folders per projects).
When I run the code with my code window open, I can see what the code is doing because of debug.print
, but since users never have the code window open, they can't see what's going on. I thought about 2 solutions.
- Open the "immediate window" as a pop-up over my form.
- Create a form with a text box.
I searched google but did not find a working solution to do the immediate window pop-up.
As for the second idea is there a way to just send the .print
to a textbox or is there something like a console object in vba?
I was using
Form_PrintWindow.PrintWindow.Text = xmlNode3.Attributes.getNamedItem("id").Text & " " & xmlNode3.Attributes.getNamedItem("name").Text & vbNewLine & Form_PrintWindow.PrintWindow.Text
But string gets full halfway in the process.
DebugOutput
and the listboxOutputList
)Add an
UpdateProgress
sub to that form. It will add the output of your other process as new items to the listbox and select the most recently added item.In your existing code, create a new instance of
Form_DebugOutput
(or whatever you named your form. Note that access automatically prepends forms withForm_
.)Instead of
Debug.Print
call theUpdateProgress
method of the form instance we created.And it will look something like this.
Outputting the results in real time like this will slow the code down, so carefully consider if you really need to display this information. Also, if you want the form to remain on screen you will need to declare the
Form
variable at a global scope. For more on this you may want to read about my progress bar.