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

Toggling Checkboxes

P: n/a
I am trying to set up a pair of checkboxes where only one may be
checked at a time BUT both should be able to unchecked as well. Thus
an option group does not work as at least one value will always be
true.

I tried:

Private Sub chkRMA_Click()
chkRMAOther = False
End Sub

Private Sub chkRMAOther_Click()
chkRMA = False
End Sub

I found that when I set the opposite checkbox value, I call its event
as well, thereby setting both to false.

Any suggestions?

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


P: n/a
<sm***********@yahoo.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
I am trying to set up a pair of checkboxes where only one may be
checked at a time BUT both should be able to unchecked as well. Thus
an option group does not work as at least one value will always be
true.

I tried:

Private Sub chkRMA_Click()
chkRMAOther = False
End Sub

Private Sub chkRMAOther_Click()
chkRMA = False
End Sub

I found that when I set the opposite checkbox value, I call its event
as well, thereby setting both to false.

Any suggestions?


I'm pretty sure that changing the setting of another control does NOT fire
that control's event. Yet I see a flaw in your logic. Remember that the
control is checked when you click it, but then it becomes unchecked when you
click it again. So if you click it a 2nd time it will become unchecked and
the other control will become unchecked, too.

Instead, try using the AfterUpdate event. Such as (air code):

Private Sub chkRMA_AfterUpdate()
If Me.chkRMA = True
Me.chkRMAOther = False
Endif
End Sub

Private Sub chkRMAOther_AfterUpdate()
If Me.chkRMAOther = True
Me.chkRMA = False
Endif
End Sub

Fred Zuckerman
Nov 13 '05 #2

P: n/a
Private Sub chkRMA_Click()
If chkRMA = True Then
chkRMAOther = False
End If
End Sub

Private Sub chkRMAOther_Click()
If chkRMAOther = True Then
chkRMA = False
End If
End Sub

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

<sm***********@yahoo.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
I am trying to set up a pair of checkboxes where only one may be
checked at a time BUT both should be able to unchecked as well. Thus
an option group does not work as at least one value will always be
true.

I tried:

Private Sub chkRMA_Click()
chkRMAOther = False
End Sub

Private Sub chkRMAOther_Click()
chkRMA = False
End Sub

I found that when I set the opposite checkbox value, I call its event
as well, thereby setting both to false.

Any suggestions?

Nov 13 '05 #3

P: n/a
rkc
sm***********@yahoo.com wrote:
I am trying to set up a pair of checkboxes where only one may be
checked at a time BUT both should be able to unchecked as well. Thus
an option group does not work as at least one value will always be
true.

I tried:

Private Sub chkRMA_Click()
chkRMAOther = False
End Sub

Private Sub chkRMAOther_Click()
chkRMA = False
End Sub

I found that when I set the opposite checkbox value, I call its event
as well, thereby setting both to false.


Really? I can't make that happen. What you have works fine for me.
What aren't you telling us?
Nov 13 '05 #4

P: n/a
if you set it up as an option group, you could leave the default value
for the group unset and skip all the setting and unsetting via if
functions. that may not work for you since once checked, some value
will always be set for the option group. you could unset the option
group programatically however by simply erasing the Value property
associated with it.

Nov 13 '05 #5

P: n/a
I stepped through it in debug mode and when I changed the value on the
other check box it took me to it's click event. Surprised me, too.
Running Visual Studio 6.0 in WIN 2000.

Nov 13 '05 #6

P: n/a
rkc
mathilda wrote:
I stepped through it in debug mode and when I changed the value on the
other check box it took me to it's click event. Surprised me, too.
Running Visual Studio 6.0 in WIN 2000.


O.K. So your using VB6 not Access for frontend development.
The Access checkboxes don't act like what you described.

Did you come up with a solution to this yet?
Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.