Home All Groups Group Topic Archive Search About

Checkbox and Click event

Author
4 Mar 2009 10:43 PM
Edward
What would cause a checkbox on a form to produce a Click event, by
setting/changing its value through code?

Just for display purposes I'm using:
'** Refresh form **
If RSr!Page = 0 Then
    chkPage.Value = 0
    Else: chkPage.Value = 1
End If

Occurs when the underlying value changes from 0 to 1, or 1 to 0, when
stepping through records, or just opening the form.
Does the Click event not really mean "Mouse click" but value change?

Author
4 Mar 2009 10:50 PM
Bob Butler
"Edward" <nospam@mail.com> wrote in message
news:JuDrl.21383$Tp5.12322@newsfe13.iad...
> What would cause a checkbox on a form to produce a Click event, by
> setting/changing its value through code?

You answered your own question.  The Click event fires when the value
changes.  If you want to ignore events triggered from code you have to code
for it.  One method:

Private mbFromCode As Boolean

Private Sub chkPage_Click()
If not mbFromCode Then
  ' handle user click
end if
End Sub

....
'** Refresh form **
mbFromCode=True
If RSr.Fields("Page").Value = 0 Then
  chkPage.Value = vbUnchecked
Else
  chkPage.Value = vbChecked
End If
mbFromCode=False
Author
5 Mar 2009 4:39 AM
Edward
Show quote Hide quote
"Bob Butler" <noway@nospam.ever> wrote in message
news:OQxTDvRnJHA.1288@TK2MSFTNGP02.phx.gbl...
>
> "Edward" <nospam@mail.com> wrote in message
> news:JuDrl.21383$Tp5.12322@newsfe13.iad...
>> What would cause a checkbox on a form to produce a Click event, by
>> setting/changing its value through code?
>
> You answered your own question.  The Click event fires when the value
> changes.  If you want to ignore events triggered from code you have to
> code for it.  One method:
>
> Private mbFromCode As Boolean
>
> Private Sub chkPage_Click()
> If not mbFromCode Then
>  ' handle user click
> end if
> End Sub
>
> ...
> '** Refresh form **
> mbFromCode=True
> If RSr.Fields("Page").Value = 0 Then
>  chkPage.Value = vbUnchecked
> Else
>  chkPage.Value = vbChecked
> End If
> mbFromCode=False
>

Worked like a charm.
Thanks for your time.
Author
5 Mar 2009 2:19 PM
Jeff Johnson
"Edward" <nospam@mail.com> wrote in message
news:JuDrl.21383$Tp5.12322@newsfe13.iad...

> What would cause a checkbox on a form to produce a Click event, by
> setting/changing its value through code?

> Does the Click event not really mean "Mouse click" but value change?

For a checkbox, that's absolutely correct.