Can I enable a single option in a group to be checked/unchecked?

  • Thread starter Thread starter ApriLee1983
  • Start date Start date
A

ApriLee1983

I have created an option group in a form with only one option available, so
that I may store the value when checked in another field. However, once you
check the box you cannot 'uncheck' it. Is this at all possible with only one
option field available to choose from?
 
In order to clear the option field with only one option, you would need to
create an event that triggers code to clear it. However, I'm confused as to
why you don't just use a checkbox (which is made for being turned on and off).

If you really need the option group, I would put in a double click event so
that the option field clears when you double click on the frame. It has to be
on the frame as the option control itself does not have the appropriate
event. In addition, the frame holds the data, not the option control, so you
need to clear the frame's value.

On the frame of the option group choose the event On Dbl Click. Then put in
the following code:

If Not IsNull(NameOfYourFrame) Then
Me.NameOfYourFrame.undo
Me.NameOfYourFrame = Null
End If
 
I could use a checkbox if I were able to assign the value I want to the box
and be able to store it in another field. Right now it will only store -1, or
0 value as opposed to '10' I am able to assign with an option group. Can this
be done through the checkbox?
 
The code worked great! Thank you! However, now I'm running into another
problem! The value I added for the option is placed in another field. It is
still providing the correct value; however, I have another calculated field
with that field included in it that is no longer adding up. Do I need another
code to get my field calculated correctly whether or not the box is checked?
 
For anyone that really cares the answer to that last question, I figured it
out myself after a little exploration. The reason it messed up the calculated
fields is because it was =Null. I changed it to =0 and the formula was
calculated correctly.
 
In reality, you can set the value of the hidden textbox based on the status
of the checkbox. Thus, if the checkbox is checked, then the textbox has a
value of "10". You don't actually have to store the value in the checkbox
this way.

However, since you got the code to work the way you want, no sense in
messing with it unless you are having problems with the database being slow.
 
When you originally posted, I did not know that the value you were looking
for was numeric. In addition, I did not know it would be used in a
calculation.

When requesting assistance, it is best to give too much information rather
than too little.

I'm glad you were able to figure this out on your own.
 
Back
Top