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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toggle CheckBox Without On_Click event firing

Status
Not open for further replies.

ARCITS

Programmer
Apr 4, 2002
99
0
0
GB
I need to use a CheckBox to toggle a condition ON or OFF.
The problem is that when I have established whether the CheckBox was ticked or not on entry into it's 'On Click' event I then need to toggle it the other way.
I am doing this by CheckBox.Value=vbChecked (if it was previously UnChecked) and CheckBox.Value=vbUnChecked (if it was previously Checked).
The problem I have is that by doing this the On_Click event is firing again.
I have found a way around this by setting a boolean variable to establish whether the On_Click event has been fired by the user or the code described above.
This works but is is not very elegant.
Are there any better ways to handle this?
Can the events be turned on and off as this would be one solution?

Any tips appreciated.

Regards
 
mabe you could use a flag in addition to your if then statement, then if the event fired and sent it through the loop again you can exit sub


 
Yeah I thought that was the only solution.
I just wondered if it was possible programatically to turn on/off the event handling, or whether there was some other trick I was missing?


Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top