-
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…
-
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.
-
You obviously need some beer, urgently.
Cheers,
P.
-
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
-
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)
-
The rbc variable will have to be either module level, or stored as a static variable inside the sub.
- gaffa
-
yeah, sorry that was the idea
you have to put Dim Rbc as Boolean in your General DEclarations part and then it will work
-
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