Command buttons not responding-sticking

L

LuisE

I have a form with 30 command buttons that give a label certain value when
clicked

i.e
Private Sub Chk12_Click()
TxtLabel.Value = "12"
End Sub

The problem arises when sometimes it takes several clicks on the same button
to update the value of the label.

Thanks in advance for your help
 
S

smartin

LuisE said:
I have a form with 30 command buttons that give a label certain value when
clicked

i.e
Private Sub Chk12_Click()
TxtLabel.Value = "12"
End Sub

The problem arises when sometimes it takes several clicks on the same button
to update the value of the label.

Thanks in advance for your help

Perhaps insert a well-placed "DoEvents".

Aside, an application with a form with 30 command buttons is crying for
an updated design.
 
L

LuisE

Thanks smartin

I know, 30 cmds ais too much but that's how my boss wants it.

Could you please ilustrate the use of DoEvents if possible?
Thanks
 
F

FSt1

hi
sub yoursub()
some code
doevents
more code
doevents
still more code
doevents
maybe some more code
end sub
the doevents keyword turns control over to the operating system to complete
tasks in it's cache. when compled, control reverts back to the macro. in a
way, it's like pausing the macro so the operating system can "keep up".
sometimes you don't want this but sometimes not letting the operating system
perform it's thing causes problems. it's a macro to macro thing so if you are
experencing problems, the doevents may help. but then again maybe not. try it
and see.
can you say the word...troubleshoot?
also.....have you had your boss's IQ check lately?

regards
FSt1
 
S

smartin

Look for places in your code where loops might be consuming lots of CPU
time, and insert DoEvents:

For i = 1 to HugeNumber
DoEvents ' to update stuff before the CPU bust
' expensive calculation/sub/function call
' more stuff
' or put DoEvents here if you want to wait
' until the first iteration is complete
Next i


As concerns the way the boss wants it, this might be an opportunity to
impress your boss with a well designed UI that does not involve hunting
about for the right button to click (^:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top