Consulting

Results 1 to 4 of 4

Thread: Solved: Need help with Click Event of OptionButton / CheckBox

  1. #1
    VBAX Newbie
    Joined
    Mar 2009
    Posts
    5
    Location

    Unhappy Solved: Need help with Click Event of OptionButton / CheckBox

    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?

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Newbie
    Joined
    Mar 2009
    Posts
    5
    Location
    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 [vba]Public manualbycb As Boolean[/vba] and [vba]Public manualbyob As Boolean[/vba], 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.
    Last edited by alita; 03-12-2009 at 01:31 AM.

  4. #4
    VBAX Newbie
    Joined
    Mar 2009
    Posts
    5
    Location
    Well, I finally managed to do it with some more help of google So this issue is solved for me now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •