General discussion

Locked

Accwess 97 Checkboxes

By doublex_us ·
I have three checkboxes. Only one is supposed to be
checked. I need to have a routine in each checkbox to checl the other two checkboxes toe if they are checked if so to uncech them?
Can anyone help me.
THanks for any help?
David

This conversation is currently closed to new comments.

11 total posts (Page 1 of 2)   01 | 02   Next
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Accwess 97 Checkboxes

by DKlippert In reply to Accwess 97 Checkboxes

I think '97 had it:
When you set up your form, use Option Group from the Toolbox. The Wizard should help you build up the group of check boxes. At least in 2000 and 2002 it works great.

Collapse -

Accwess 97 Checkboxes

by doublex_us In reply to Accwess 97 Checkboxes

The question was auto-closed by TechRepublic

Collapse -

Accwess 97 Checkboxes

by Bob Sellman In reply to Accwess 97 Checkboxes

Create an option group. Within the option group put either three check boxes or three radio buttons.

When you check one box, if another box in the group is already checked, it will be unchecked automatically.

You can then base your actions onthe value of the option group. The value is a result of which check box has been checked.

Collapse -

Accwess 97 Checkboxes

by Bob Sellman In reply to Accwess 97 Checkboxes

For the onUpdate property of the group, assuming you have set the values of the check boxes to 1, 2, and 3, use something like the following code:

' assume three not visible controls on your form that correspond to each of the areas you need to post the results from selecting one of the three check boxes. I'll call the controls txt1, txt2, and txt3.

SELECT me.grp
CASE 1
me.txt1=True
me.txt2=False
me.txt3=False
CASE 2
me.txt1=False
me.txt2=True
me.txt3=False
CASE 3
me.txt1=False
me.txt2=False
me.txt3=True
END SELECT

It sounds like you want to do more than just set one out of three fields to true and the other two to false, so substitute whatever you want to do for the lines above that set txt1, txt2, and txt3 to true or false.

You could also add functions to your form that would enable you to perform either the true or the false action on whatever control name you passed to the function. That would be a good way to go if each selection results in an elaborateset of actions.

Collapse -

Accwess 97 Checkboxes

by doublex_us In reply to Accwess 97 Checkboxes

The question was auto-closed by TechRepublic

Collapse -

Accwess 97 Checkboxes

by doublex_us In reply to Accwess 97 Checkboxes

I tried what you suggested, but that will not work I need to store the answer in separate field bases on state requirements. The groupe option does not give me a choice where to store the data, only one field.

Collapse -

Accwess 97 Checkboxes

by sl-campbell In reply to Accwess 97 Checkboxes

Do not use a group! It will mess things up in your case.
Fist, set the default values of the check boxes in the property window.
Then go to the code window in the class module of the form.
Find in the left drop-down the first check box. Once clicked, the event code will be placed in the code window. Add to that code and IF statement, checking the value of the check box and then the names of the other 2 check boxes with their vale properties. Set the value properties to what you want.

Something like:
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
CheckBox2.Value = False
CheckBox3.Value = True
End If
End Sub

Which also could be written like:

Private Sub CheckBox1_Click()
CheckBox2.Value =Not CheckBox1.Value
CheckBox3.Value = CheckBox1.Value
End Sub

Do the same thing for the other 2 check boxes, setting the values accordingly.

Now, what you will have to do is decide what happens to the check boxes when you change records. You can add the Form_Current event to the code window as well and set the values of the check boxes according, based on the value(s) of the other check box(es). Normally, if these are bound controls, the values in the fields should already reflect the business rules, and therefore the checkboxes should already have the correct values, but as an extra safe guard you can set the values in the Form_Current event.

Collapse -

Accwess 97 Checkboxes

by doublex_us In reply to Accwess 97 Checkboxes

The question was auto-closed by TechRepublic

Collapse -

Accwess 97 Checkboxes

by irv In reply to Accwess 97 Checkboxes

I think your problem is trying to generate a value in 3 different fields based on the status of the radio buttons. Radio buttons are boolean values true/false,1/0,yes/no so can oly be stored as boolean values. The suggested grouping will work if youput a "changed" VB routine on it such as if rb1 true
rb1-field = true
else
rb1-field = false
if rb2 true
rb2-field = true
else
rb2-field = false
' where rb3 now has to be true since rb1, rb2 are false
rb3-field = true

or something like this. The key is the grouping controls the "only one true" condition. If you only used one field to represent the status of the group, i think it stores a value in the control field for the group that reflects its status.

Collapse -

Accwess 97 Checkboxes

by doublex_us In reply to Accwess 97 Checkboxes

The question was auto-closed by TechRepublic

Back to Web Development Forum
11 total posts (Page 1 of 2)   01 | 02   Next

Related Discussions

Related Forums