Updating form labels from code in a module

  • Thread starter Thread starter news.verizon.net
  • Start date Start date
N

news.verizon.net

I have a VBA program that creates an Excel database from raw data in a flat
file. I launch the program from a command button on a user form. I also have
labels on the form that I would like to update with "lines processed" and
"records completed" numbers, both of which are variables in the program, but
I can't figure out where to put the code to update the labels. Whether I put
the code in the userform module or the main module where the program is, the
labels don't update. Do I need to have some sort of dynamic link between the
form and main modules so they can exchange variables?
I also have a stop command button on the form that I would like to use to
terminate the program if the user clicks it, but the program is mainly a do
loop and once it enters the loop it doesn't check the form code to see if
the button has been pressed.
Any help would be greatly appreciated. I'm relatively new at this.

Thanks,
Chris
 
That was it!
Thanks Paul!

It may be that you just need to add DoEvents statements in your code.
See the following example by John Walkenbach.

http://j-walk.com/ss/excel/tips/tip34.htm

HTH
Paul
-------------------------------------------------------------------------- ------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
-------------------------------------------------------------------------- ------------------------------------
 
Back
Top