Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Status messages in a form while code is running

Status
Not open for further replies.

filotei

Programmer
Mar 11, 2003
7
RO
hello everybody,
does anybody knows what code should be used to display status messages in a userform (textbox or label in the form) while code is running?
thank you very much for any idea.
filotei
 
Just update the controls from within your code. You may also want to lookat SysCmd which includes a way to display messages on the Status Bar at the bottom of the screen.

Good Luck!
 
thanks for your prompt reply
i am quite new in vba excel and i am not sure i understood. how can i update the controls? i wrote down something like this
Code:
userform1.view

do
counter=counter+1
Application.StatusBar=counter ' it's displayed on the statusbar - ok
textbox1.value=counter 'it is not displayed while code is running - only the last value - i would like to see the changes in the textbox from 1 to 10
loop until counter=10
where am i wrong?

thank you again for your help

filotei
p.s. i didn't find syscmd in vba excel
 
actually it is a code for a clik event of commandbutton1. i would like to see the status of the code in the textbox1. the commandbutton1 and the textbox1 are on the same userform.
hope i was clear enogh now
thank you very much for your assistance
filotei
 
Try putting the statement "DoEvents" after your textbox assignment. I wouldn't think it's necessary, but if it's not updating, that would be my first try. Are you sure it's not just that the updates are so fast that you only see the last one?
Rob
[flowerface]
 
Hi filotei,

Userform displays are not automatically refreshed while code associated with them is still running because the refreshing is a 'system' action and the 'system' does not have control. There are a couple of things you can do:

The best is to do what Rob says and add the "DoEvents". This momentarily releases control to the system for it to do whatever it thinks needs doing (which might occasionally include things you don't want to happen).

As an alternative you can explicitly refresh the display without relinquishing control by using the Repaint method ("Userform1.Repaint") but in a tight loop like your example this would probably cause the form to flicker.

Enjoy,
Tony
 
hi rob and tony
thank you very much for your suggestions. they both worked!the repaint method cause indeed flickers but i found a solution to repaint the userform only a few times during the code running and the user do not see the flickers.
thanks again
filotei
 
Sorry Filotei, my answer pertained to Access, not Excel. My apologies for posting incorrect information.
 
yes the progressbar is another possibility. i haven't tried yet but i will make some researches, as i don't know exactly how it works
thanks for the suggestion
filotei
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top