By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,117 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,117 IT Pros & Developers. It's quick & easy.

Trapping Click With Calculated Check Box

P: n/a
I have a check box on a form that's bound to a function that returns a
True/False value. When the user clicks on the check box, I run some code
through the MouseDown event. Everything works fine.

Only problem is: when the user clicks on it, there's a beep, and then they
get a status bar message: "Control can't be
edited; it's bound to the expression...." That's very annoying and
disconcerting.

Is there a way to trap the click and avoid the message? The Access online
help says that MouseDown can't be canceled. And OnClick and BeforeUpdate
don't seem to be called when it's a calculated control. Anyone have any
ideas on how to work around this?

I would put a command button on top of the check box; but the users need to
be able to work with it in Datasheet View, and command buttons don't appear
there.

Any ideas?

Thanks!

Neil
Nov 13 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi,
once you have a control with function in control source - you can't update
it. instead you can set a default value property to this function, and leave
control source blank (or bind to a updatable field)

command buttons does not appear on datasheet view, but you can use a
continuous form for this

--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
"Neil" <no****@nospam.net> wrote in message
news:ML****************@newsread2.news.pas.earthli nk.net...
I have a check box on a form that's bound to a function that returns a
True/False value. When the user clicks on the check box, I run some code
through the MouseDown event. Everything works fine.

Only problem is: when the user clicks on it, there's a beep, and then they
get a status bar message: "Control can't be
edited; it's bound to the expression...." That's very annoying and
disconcerting.

Is there a way to trap the click and avoid the message? The Access online
help says that MouseDown can't be canceled. And OnClick and BeforeUpdate
don't seem to be called when it's a calculated control. Anyone have any
ideas on how to work around this?

I would put a command button on top of the check box; but the users need
to be able to work with it in Datasheet View, and command buttons don't
appear there.

Any ideas?

Thanks!

Neil

Nov 13 '05 #2

P: n/a
Yes, I know you can't update a calculated control. What I wrote was that I
handle any updating through the MouseDown event. What I am trying to do is
trap the message that I noted in my original post so that the user does not
receive it.

And, yes, Continuous Forms would work, but the client insists on Datasheet
View (they like being able to hide and show columns, resize columns, and
change the order of columns).

Neil
"Alex Dybenko" <al*****@PLEASE.cemi.NO.rssi.SPAM.ru> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
Hi,
once you have a control with function in control source - you can't update
it. instead you can set a default value property to this function, and
leave control source blank (or bind to a updatable field)

command buttons does not appear on datasheet view, but you can use a
continuous form for this

--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
"Neil" <no****@nospam.net> wrote in message
news:ML****************@newsread2.news.pas.earthli nk.net...
I have a check box on a form that's bound to a function that returns a
True/False value. When the user clicks on the check box, I run some code
through the MouseDown event. Everything works fine.

Only problem is: when the user clicks on it, there's a beep, and then
they get a status bar message: "Control can't be
edited; it's bound to the expression...." That's very annoying and
disconcerting.

Is there a way to trap the click and avoid the message? The Access online
help says that MouseDown can't be canceled. And OnClick and BeforeUpdate
don't seem to be called when it's a calculated control. Anyone have any
ideas on how to work around this?

I would put a command button on top of the check box; but the users need
to be able to work with it in Datasheet View, and command buttons don't
appear there.

Any ideas?

Thanks!

Neil


Nov 13 '05 #3

P: n/a
What's the code that you're running, and what is it supposed to be doing?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Neil" <no****@nospam.net> wrote in message
news:ML****************@newsread2.news.pas.earthli nk.net...
I have a check box on a form that's bound to a function that returns a
True/False value. When the user clicks on the check box, I run some code
through the MouseDown event. Everything works fine.

Only problem is: when the user clicks on it, there's a beep, and then they
get a status bar message: "Control can't be
edited; it's bound to the expression...." That's very annoying and
disconcerting.

Is there a way to trap the click and avoid the message? The Access online
help says that MouseDown can't be canceled. And OnClick and BeforeUpdate
don't seem to be called when it's a calculated control. Anyone have any
ideas on how to work around this?

I would put a command button on top of the check box; but the users need
to be able to work with it in Datasheet View, and command buttons don't
appear there.

Any ideas?

Thanks!

Neil

Nov 13 '05 #4

P: n/a
It basically adds an item to a collection to store the "checked" values, and
removes an item for "unchecked" values. The check box, itself, is bound to
the formula "=IsSelected([ID])" where IsSelected() returns True or False,
based on whether or not the item's in the collection.

Thus, when the user clicks on the check box, the MouseDown event is
triggered, which toggles whether or not the record is represented in the
collection. Unfortunately, it also triggers the message I noted, saying you
can't update the control. If I can just get rid of that message, it would be
fine.

Neil
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:eK**************@TK2MSFTNGP09.phx.gbl...
What's the code that you're running, and what is it supposed to be doing?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Neil" <no****@nospam.net> wrote in message
news:ML****************@newsread2.news.pas.earthli nk.net...
I have a check box on a form that's bound to a function that returns a
True/False value. When the user clicks on the check box, I run some code
through the MouseDown event. Everything works fine.

Only problem is: when the user clicks on it, there's a beep, and then
they get a status bar message: "Control can't be
edited; it's bound to the expression...." That's very annoying and
disconcerting.

Is there a way to trap the click and avoid the message? The Access online
help says that MouseDown can't be canceled. And OnClick and BeforeUpdate
don't seem to be called when it's a calculated control. Anyone have any
ideas on how to work around this?

I would put a command button on top of the check box; but the users need
to be able to work with it in Datasheet View, and command buttons don't
appear there.

Any ideas?

Thanks!

Neil


Nov 13 '05 #5

P: n/a
And what's the actual code you're using?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Neil" <no****@nospam.net> wrote in message
news:Qq****************@newsread2.news.pas.earthli nk.net...
It basically adds an item to a collection to store the "checked" values,
and removes an item for "unchecked" values. The check box, itself, is
bound to the formula "=IsSelected([ID])" where IsSelected() returns True
or False, based on whether or not the item's in the collection.

Thus, when the user clicks on the check box, the MouseDown event is
triggered, which toggles whether or not the record is represented in the
collection. Unfortunately, it also triggers the message I noted, saying
you can't update the control. If I can just get rid of that message, it
would be fine.

Neil
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:eK**************@TK2MSFTNGP09.phx.gbl...
What's the code that you're running, and what is it supposed to be doing?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Neil" <no****@nospam.net> wrote in message
news:ML****************@newsread2.news.pas.earthli nk.net...
I have a check box on a form that's bound to a function that returns a
True/False value. When the user clicks on the check box, I run some code
through the MouseDown event. Everything works fine.

Only problem is: when the user clicks on it, there's a beep, and then
they get a status bar message: "Control can't be
edited; it's bound to the expression...." That's very annoying and
disconcerting.

Is there a way to trap the click and avoid the message? The Access
online help says that MouseDown can't be canceled. And OnClick and
BeforeUpdate don't seem to be called when it's a calculated control.
Anyone have any ideas on how to work around this?

I would put a command button on top of the check box; but the users need
to be able to work with it in Datasheet View, and command buttons don't
appear there.

Any ideas?

Thanks!

Neil



Nov 13 '05 #6

P: n/a
i am not sure, but i think MouseDown event also cause checkbox update, that
is why you get error message

as for datasheet with buttons - you can do this in Access. but you can try
to use some activex control, for example with janus grid you can do this:
www.janusys.com

--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
"Neil" <no****@nospam.net> wrote in message
news:oX****************@newsread3.news.pas.earthli nk.net...
Yes, I know you can't update a calculated control. What I wrote was that I
handle any updating through the MouseDown event. What I am trying to do is
trap the message that I noted in my original post so that the user does
not receive it.

And, yes, Continuous Forms would work, but the client insists on Datasheet
View (they like being able to hide and show columns, resize columns, and
change the order of columns).

Neil
"Alex Dybenko" <al*****@PLEASE.cemi.NO.rssi.SPAM.ru> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
Hi,
once you have a control with function in control source - you can't
update it. instead you can set a default value property to this function,
and leave control source blank (or bind to a updatable field)

command buttons does not appear on datasheet view, but you can use a
continuous form for this

--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
"Neil" <no****@nospam.net> wrote in message
news:ML****************@newsread2.news.pas.earthli nk.net...
I have a check box on a form that's bound to a function that returns a
True/False value. When the user clicks on the check box, I run some code
through the MouseDown event. Everything works fine.

Only problem is: when the user clicks on it, there's a beep, and then
they get a status bar message: "Control can't be
edited; it's bound to the expression...." That's very annoying and
disconcerting.

Is there a way to trap the click and avoid the message? The Access
online help says that MouseDown can't be canceled. And OnClick and
BeforeUpdate don't seem to be called when it's a calculated control.
Anyone have any ideas on how to work around this?

I would put a command button on top of the check box; but the users need
to be able to work with it in Datasheet View, and command buttons don't
appear there.

Any ideas?

Thanks!

Neil



Nov 13 '05 #7

P: n/a
Below is the code I'm using. It's adapted from Albert Kallal's multi-select
example, except that his uses a command button on top of the check box
(which avoids the problem I'm having, but doesn't work in Datasheet View).
The check box is bound to "=IsChecked([Index])", where Index is the PK of
the record.

Neil

Dim colSelect As New Collection

Private Sub ExportSel_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)

ExportSelCheck

End Sub

Private Sub ExportSel_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = vbKeySpace Then
KeyCode = 0
ExportSelCheck
End If

End Sub

Private Sub ExportSelCheck()

DoCmd.Echo False

If Not IsChecked(Me!Index) Then
colSelect.Add CLng(Me!Index), CStr(Me!Index)
Else
colSelect.Remove (CStr(Me!Index))
End If

Me.ExportSel.Requery

DoCmd.Echo True

End Sub

Public Function IsChecked(vID As Variant) As Boolean

Dim lngID As Long

If Not IsMember(vID) Then Exit Function

lngID = colSelect(CStr(vID))
If lngID <> 0 Then
IsChecked = True
End If

End Function

Private Function IsMember(vID) As Boolean

Dim var As Variant

For Each var In colSelect
If var = vID Then
IsMember = True
Exit For
End If
Next

End Function
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:ue**************@TK2MSFTNGP09.phx.gbl...
And what's the actual code you're using?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Neil" <no****@nospam.net> wrote in message
news:Qq****************@newsread2.news.pas.earthli nk.net...
It basically adds an item to a collection to store the "checked" values,
and removes an item for "unchecked" values. The check box, itself, is
bound to the formula "=IsSelected([ID])" where IsSelected() returns True
or False, based on whether or not the item's in the collection.

Thus, when the user clicks on the check box, the MouseDown event is
triggered, which toggles whether or not the record is represented in the
collection. Unfortunately, it also triggers the message I noted, saying
you can't update the control. If I can just get rid of that message, it
would be fine.

Neil
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:eK**************@TK2MSFTNGP09.phx.gbl...
What's the code that you're running, and what is it supposed to be
doing?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Neil" <no****@nospam.net> wrote in message
news:ML****************@newsread2.news.pas.earthli nk.net...
I have a check box on a form that's bound to a function that returns a
True/False value. When the user clicks on the check box, I run some code
through the MouseDown event. Everything works fine.

Only problem is: when the user clicks on it, there's a beep, and then
they get a status bar message: "Control can't be
edited; it's bound to the expression...." That's very annoying and
disconcerting.

Is there a way to trap the click and avoid the message? The Access
online help says that MouseDown can't be canceled. And OnClick and
BeforeUpdate don't seem to be called when it's a calculated control.
Anyone have any ideas on how to work around this?

I would put a command button on top of the check box; but the users
need to be able to work with it in Datasheet View, and command buttons
don't appear there.

Any ideas?

Thanks!

Neil



Nov 13 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.