Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

yes/no check box

Status
Not open for further replies.
Feb 25, 2005
30
GB
Hi,
Is there a way of using two check boxes so that there is one for yes and one for no, dependant on which is selected it is inputted into the same table field?

Am I right in saying that the default is just one box in forms based on the selection within the table for yes/no?

I tried using a combo box but for some reason I am not getting the dropdown selection of yes/no just a blank!

Any help would be greatly appreciated

Rachel
 
The usual way is one CheckBox for one Boolean field.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Rather than a check box, "option button group" would be more appropriate. From MS Acess Help:

"You can use an option group on a form... to display a limited set of alternatives. An option group makes selecting a value easy because you can just click the value that you want. Only one option in an option group can be selected at a time." Whichever option you choose is then assigned to the single field in the table.

To learn about using option groups, just enter "option group" in the Access Help Wizard.

Hope this helps!

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
Rachel

Is there a way of using two check boxes so that there is one for yes and one for no

Yes. One approach would be to use the AfterUpdate event procedure to change the value of the other check box.

Assumptions:

chkBox1 - first check box
chkBox2 - second check box

Code:
Private Sub chkBox1_AfterUpdate()

   Me.chkBox2 = me.chkBox1  * -1

End Sub

Private Sub chkBox2_AfterUpdate()

   Me.chkBox1 = me.chkBox2  * -1

End Sub


Am I right in saying that the default is just one box in forms based on the selection within the table for yes/no

As suggested by PHV, usually so if the boolean field is used to determine the value for one attribute.

You may wish to read up on design...
Fundamentals of Relational Database Design by Paul Litwin
Download document
Read on-line (HTML)

Micro$oft's answer to design and relationships...
Where to find information about designing a database in Microsoft Access
283878 - Description of the database normalization basics
304467 - ACC2000 Defining Relationships Between Tables in a Microsoft Access Database

I tried using a combo box...

Your idea of a combo box is a good choice -- you can take a boolean value and display a more meaningful text message such as "Accepted", "Passed" or "Deficient" instead of the Yes/No True/False.

missinglinq's idea of using an Option Group is also a good idea.

The one thing we are missing is what is the purpose of the Yes/No field. It would help in determining the best answer.

Richard
 
thanks guys for the responses, I have gone with "option button group" as suggested; and it works a treat.

Much appreciated
Rachel
 
Richard,
I'm sorry if I'm being dense, but I don't understand your example. If a checkbox's value is either 0 (false) or -1 (true), doesn't your code cause *both* checkboxes to be either 0 (0 * -1 = 0, both display false) or -1 and 1 (-1 * -1 = 1, both display true)? What am I missing? Wouldn't
Code:
Me.chkBox2 = Not Me.chkBox1
and vice versa be better?

Ken S.
 
My bad Ken. I was working on another project that did require -1*, and I lost my focus. Thanks for the correction.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top