View Full Version : Solved: Need help with Click Event of OptionButton / CheckBox

03-11-2009, 03:29 AM
Hi all,

I have the following problem and couldn't find anything in this forum and with Google which would help me:
How can I avoid that when I set the value of a CheckBox or an OptionButton to true in the programm code the Click-Event of this CheckBox / OptionButtons is called?
To explain it a little further: I have a worksheet with OptionButtons and CheckBoxes on it. Now I have one line in the program code for the Click-Event of the CheckBox that under certain circumstances, the value of the OptionButton is set true and vice versa.
At Microsoft's MSDN I found out that the Click-Event of a CheckBox / OptionButton is called everytime the value of it gets set to true. But that makes my program canceling with errors in the end. So I somehow have to avoid that the Click-Procedure is called when the value of an OptionButton / CheckBox is set to true in the program code or I need another event (instead of "Click") under which I can put my program code.

Does anyone have any ideas, please?

03-11-2009, 03:52 AM
Why not just have a public boolean variable which you set when you don't want it execeuted, and check that variable in the click event.

03-12-2009, 12:15 AM
Hm, this could be an idea... But then I need some further help with this:
I have one Class Module for all CheckBoxes and one for all OptionButtons so that I can have one Click-Procedure for all of them. They are called clsOptionbutton and clsCheckbox. Now I tried to have a Boolean for each Public manualbycb As Boolean and Public manualbyob As Boolean, set it true when I changed the value of an optionbutton or checkbox in the program code and had it checked at the beginning of the Click-Event (if false, then program code is executed). This part works, but the setting of the variable doesn't. I reconsidered with MsgBoxes that the Boolean isn't set in the way I want it to be. So my question is whether there is a special way to adress that Boolean variable (I only call it by manualbycb / manualbyob) or do I have to set it as a Class variable or something? I'm not too familiar with VB, that's why I'm asking...
(I think I made the mistake not to have "Option Explicit" at the beginning of each of my code modules)


I did some Google research and now I know what I am looking for: I need a way to declare a variable in a Class module which is independent from each object of the class and can be accessed not only in this Class module but also through other code modules.

Anything I tried out with "shared" or "public" did not work so far so I appreciate any help or idea how to declare the variable.

03-12-2009, 07:04 AM
Well, I finally managed to do it with some more help of google ;) So this issue is solved for me now.