store value for an option group?

pablofonto

Registered User.
Local time
Today, 08:29
Joined
Sep 8, 2005
Messages
79
Hello Everyone,

I'm not sure if this is possible. I have a form (link to a table) with option boxes that when I click on one of the option boxes sets a value to a field in the table. The problem is that when I check a different option box I have to manually uncheck the other option box that was previously checked. Is there a way to have this done automatically? Meaning that if I check box 1 and then box 2, when I check box 2, then box 1 has to get Unchecked.

I also tried using a group option with different option boxes and that seems to work fine as far keeping only one option box checked, but don't know how to make the checked box to store its value to a table. Please help!
:confused:
Thanks!
 
You will need to create a "Options Group" and then place the "Check Box" or "Option Buttons" in the "Options Group" box therefore creating an "array" in which case u can only select one item, it will check and uncheck automaticly.
 
Thank you Jelly Fish! but how would you go to store the value of the check box into a table. Normaly the value is set to -1 but don't know how reference the check box to a field in a table.
 
I'm still trying to figure this one out, but it's still not working. Does anyone else have any ideas? Please help!

Thanks!

PF
 
Each option should put a different Integer in the field. The value is defined in the OptionValue slot of the Data tab of the property sheet for each "button/chkbox"
 
I know where the value is found in the form property, but how do you save that value to a table field? I'm so confuse with this issue!
 
You bind the OptionGroup ControlSource to the field in the underlying table/query.
 
RuralGuy, thanks for your help on this but still doesn't work. I included a picture of my form to see if this helps explaining the situation. In the picture you see Frame25 with 3 option buttons, I have a table also with 3 fields "Create", "Maintain" and "Delimit". In my form when I go into the properties and click on control source I get the 3 fields from my table but I can only select one. This is how I need this to work, if I select "create" as the option I want it to save it's value (-1) in the "create" field of my table. If I choose any of the other two options I want them to add the value to their similar field in the table
 

Attachments

I'm afraid the way you are doing it with three fields in the table will require you to "roll your own" in the AfterUpdate event of three separate CheckBoxes. An Option group will not work for your particular situation. With code you can make it look and act just like an OptionGroup.
 
RuralGuy, I'm not too familiar with codes. Can you give me an example what you think might work?

thanks!
 
In the BeforeUpdate event of your three CheckBoxes you will need something like:
Code:
Private Sub ChkBox1_BeforeUpdate(Cancel As Integer)

If Me.ChkBox1 Then
   '-- We just checked this checkbox
   Me.ChkBox2 = False
   Me.ChkBox3 = False
Else
   '-- Ignore the uncheck click
   Cancel = True
End If

End Sub
Using your CheckBox names of course and changing the true side to point to the other two CheckBoxes.
 
Thank you RG! I'll try that and will let you know if it worked.
 
:( Still didn't work. I might be doing something wrong! I think I'm giving up on this and I'm just going to have my end users to check the option they want and uncheck the options they don't want.

Thanks anyway for your help RG!

PF
 
I know it works because I tried it on one of my forms with several CheckBoxes. You need the three CheckBoxes bound to their respective fields and start them off at 0 or False. Post the code you used from Private to End Sub please.
 
Since I'm not familiar with codes I'm pretty sure that it doesn't work because something is wrong. Here is what I did.

Private Sub Create_BeforeUpdate(Cancel As Integer)

If Me.Create Then
'-- We just checked this checkbox
Me.Maintain = False
Me.Delimit = False
Else
'-- Ignore the uncheck click
Cancel = True
End If

End Sub
 
That looks good. Do you have similar code in the BeforeUpdate events of Maintain and Delimit? If it does not work, what does it do? Does it do anything? It will *not* switch a checkbox from "Checked" to "UnChecked" directly by design. On;y Checking one of the other checkboxes will "UnCheck" this one.
 
RG, the boxes do change when I click one or the other. The problem is that still doesn't update the three different fields in my table. I think I'm going to link a table with just one field "results" and then use an update query to update another table with the three fields "Create", "Maintain" and "Delimit".
Then on my quey I can say if Results is 1, then update Create = -1. If Results is 2, then Maintain = -1 or if Results is 3, then Delimit =-1.
What do you think?

PF
 
Did you bind (set the ControlSource) all of the CheckBoxes to the fields in the underlying table/query?
 
If you're still having trouble storing the options to an underlying field, then your best bet is to just use the Option Group Wizard. It will ask you where you want the results stored.
 
I doubt posting to a 6 year old thread will be useful.
 

Users who are viewing this thread

Back
Top Bottom