The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
checkbox_OnClick
Posted: 17 Sep 07 12:47 PM
|
I'm trying to monitor when a user checks/unchecks a checkbox, but after security checks are done for a user to determine whether this checkbox should be enabled or not, code that I have written for the OnClick event of this checkbox is being triggered everytime the security checks are made.
I've also tried putting the code on the OnMouseUp event, but that didn't help. Is there anyway I can monitor when this checkbox is changed by a user?
I'd appreciate any help. Thanks. |
|
|
|
Re: checkbox_OnClick
Posted: 17 Sep 07 6:32 PM
|
I am suprised you have had trouble with the OnMouseUp event. The OnClick event for the checkbox has always been problematic because it fires on the opening of the form and refreshes (not just when a user clicks). I would look at your code to see what might be happening there because the OnMouseUp or OnMouseDown event should trigger the event when the checkbox is being clicked.
Ted |
|
|
|
Re: checkbox_OnClick
Posted: 17 Sep 07 10:25 PM
|
If running 6.2.x and higher (not sure if 6.1 has it), you could do the following:
Sub CheckBox1Click(Sender) if Not Form.IsReading then 'Replace Form for your forms Name 'Do Stuff here End If End Sub
By executing only if the form isn't reading, then you bypass the firing when the Form is loading or Refreshing. Also, keep in mind that if you change the value of the checkbox itself from this event, it will fire one more time. [It doesn't go into an infinite loop], but you might have to do something like this:
Dim isTesting isTesting = False Sub CheckBox1Click(Sender) if Not Form.IsReading and Not isTesting then 'Replace Form for your forms Name isTesting = True ' This prevents the second iteration from executig your code. 'Do Stuff here ' isTesting = False End If End Sub
|
|
|
|
Re: checkbox_OnClick
Posted: 18 Sep 07 8:21 AM
|
Ted,
Thank you for your input. It's not that the OnMouseUp and OnClick events are not being triggered. They are triggered when I click on the checkbox. The problem is that these are also being triggered when the form opens and when I move to another account even though I did not click on the checkbox. I need to have this triggered only when I click on it. |
|
|
|
Re: checkbox_OnClick
Posted: 18 Sep 07 10:45 AM
|
Hi Laura,
As Raul mentioned, the IsReading form property will allow you to distinguish between when the checkbox is checkbox because a user checked it or when it is set from data binding.
Sub CheckBox1Click(Sender) If Not IsReading Then 'User clicked the checkbox Else 'Checkbox was set from databinding End If End Sub
Does that make sense?
-Ryan |
|
|
|
Re: checkbox_OnClick
Posted: 18 Sep 07 4:05 PM
|
Raul and Ryan:
I just tried your solution and it worked. Thank you so very much.
Laura |
|
|
|