Re: One check box or the other
- From: Klatuu <Klatuu@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 20 Jul 2006 09:18:02 -0700
Triple state makes perfect sense for this. You say that they cannot be the
same, but in some cases neither would be selected. Well, those two
statements appear to contridictory, because neither selected would make them
both uncheced. So, to have one or the other (but not both) checked, an
option group is exactly what you want. Now, you also want it so that neither
is checked. This is the Tripe State option where the value of the option
group is Null.
If the current situation is that you have two boolean fields bound to the
current two check boxes, you can control them using a hidden check box for
each field that is the bound control. The option group would not be bound,
but you can use its After Update event to set the values of the hidden check
boxes.
Select Case Me.opgTripleChoice
Case is Null
Me.chkOne = False
Me.chkTwo = False
Case is 0
Me.chkOne = True
Me.chkTwo = False
Case is 1
Me.chkOne = False
Me.chkTwo = True
End Select
You will also want to ensure the option group is Null for new records and is
correctly set for existing records, so add this to the form's Current event:
If Me.NewRecord Then
Me.opgTripleChoice = Null
ElseIf Me.chkOne = True And Me.chkTwo = False Then
Me.optTripeChoice = 0
ElseIf Me.chkOne = False And Me.chkTwo = True Then
Me.optTripeChoice = 1
Else
Me.opgTripleChoice = Null
End If
"BruceM" wrote:
Triple-state doesn't make sense in this situation, but could come in handy.
some day. Thanks for the thought.
Do you see a way of simplifying and streamlining the coding? Again, it's
not a big deal, but I expect that anything I can learn for this situation
will prove useful in the future.
"Rick B" <Anonymous> wrote in message
news:ORjhg6ArGHA.2232@xxxxxxxxxxxxxxxxxxxxxxx
Just FYI, you can do what you are asking but, I have had a case in the
past where I used a triple-state checkbox. Perhaps this will suit your
needs.
You change the field to a number field and it stores "-1" for a checked
value, "0" for an unchecked value, and Null for a grayed out checkbox.
Again, this may or may not make sense for your particular application, but
it worked very well for us where we had an activity that was either
performed, not yet performed and required, or not yet performed and
optional.
--
Rick B
"BruceM" <bamoob@xxxxxxxxxxxxxxxxxx> wrote in message
news:%23L40gxArGHA.1368@xxxxxxxxxxxxxxxxxxxxxxx
I have a form on which are two check boxes (bound to Yes/No fields) that
cannot both be the same value. Under some circumstances neither will be
checked, so I don't think I can use an option group unless I add a third
option, which I don't want to do.
I know I can add this to one check box (and the inverse to the other):
Private Sub Check1_AfterUpdate()
Me.Check2 = Not Me.Check1
End Sub
However, I would like to know if I could handle both check boxes from a
single function (or sub), or otherwise streamline the process. The code
above, if placed in a function and called from the After Update event,
affects one check box differently than the other. I could write an If
statement to take care of both check boxes, but I wouldn't be saving
myself much coding.
My actual situation involves several pairs of check boxes, and other
cases in which a similar principle applies. It comes up often enough
that I would like to know if there is a way to handle it more
efficiently.
- Follow-Ups:
- Re: One check box or the other
- From: BruceM
- Re: One check box or the other
- References:
- One check box or the other
- From: BruceM
- Re: One check box or the other
- From: Rick B
- Re: One check box or the other
- From: BruceM
- One check box or the other
- Prev by Date: Re: Update a Date Text Box with Code
- Next by Date: Re: Date Query
- Previous by thread: Re: One check box or the other
- Next by thread: Re: One check box or the other
- Index(es):
Relevant Pages
|