Results 1 to 8 of 8

Thread: Check button question (hehehe)

  1. #1

    Thread Starter
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    I can’t think properly this morning (Rio has left!!!!).

    I have a check box on a form.

    Code is:

    Code:
     Private Sub chkList_Click()
    
    If IsReflectionsOpen = False Then
        MsgBox "Liar!"
        chkList = False
    Else
        MsgBox "OK, you're right"
    End If
    End Sub
    (The function IsReflectionsOpen checks if another totally unrelated program is open or not)

    My problem is that when the user clicks chkList (which is defaulted to False), it runs IsReflectionsOpen, and when that is finished and the check box is set to False, is runs IsReflectionsOpen again.

    Now, I could solve my problems by using a command button, but I’m stubborn, OK?

    Suggestions please…

  2. #2
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    rbc stands for raised by code.
    Code:
    Dim Rbc As Boolean
    
    If Not Rbc Then
    If Not IsReflectionsOpen Then
        MsgBox "Liar!"
        Rbc = True
        chkList = False
    Else
        MsgBox "OK, you're right"
    End If
    Else
    Rbc = False
    End If
    tell me if this helps you.


  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    You obviously need some beer, urgently.

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  4. #4

    Thread Starter
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    David

    Thanks for the response. I can see where you are coming from, but it doesn’t work. As the checkbox is set to false again (after is has been determined that IsReflectionsOpen is false), it emulate an OnClick event, thus running the code again.

    I suspect I need to store a variable outside of this sub….

    Keep them coming!

    Thanks again

    Gaff

  5. #5

    Thread Starter
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    Paul,

    Its about that time of day, isn't it. BTW, no banana with me today. Just a v v v pink tie (a la Larry Grayson)

  6. #6
    Guest
    The rbc variable will have to be either module level, or stored as a static variable inside the sub.

    - gaffa

  7. #7
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    yeah, sorry that was the idea

    you have to put Dim Rbc as Boolean in your General DEclarations part and then it will work

  8. #8
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    Code:
    'General Declarations
    Dim Rbc As Boolean
    'Check Box function
    Private Sub chkList_OnClick()
    If Not Rbc Then
    If Not IsReflectionsOpen Then
        MsgBox "Liar!"
        Rbc = True
        chkList = False
    Else
        MsgBox "OK, you're right"
    End If
    Else
    Rbc = False
    End If
    End Sub

Posting Permissions

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



Click Here to Expand Forum to Full Width