View Full Version : Multiple check boxes for one field - Access '97


liner
01-18-2001, 12:23 PM
I would like to ask a question on my form and allow the user to respond by selecting one or more of the check boxes provided. For example,

Select two of the following:

Red Yellow Green Blue

How do I get multiple values, say "Red" and "Blue" to show in my table as "Red, Blue" when the user selects these two colors?

Thanks.

Atomic Shrimp
01-19-2001, 12:02 AM
It's not advisable to store separate values in a single field, gereally speaking it causes problems later on when you want to apply criteria in a query or perform a calculation on field values, it's also a problem removing the text 'blue' from the middle of a string should the user uncheck the 'blue' checkbox.

But to your problem; you want the user to be able to select any number of the available chack boxes, each of which represents a colour? - Provided that there are and only ever will be (in your application) a finite (and fairly small) list of possible colours, you could have a yes/no field for each one, then combine the values in a query later to get the colour names all in one piece of text, like this:

SELECT IIf([FldRED]=True,"RED ","") & IIf([FldBLU]=True,"BLUE ","") & IIf([FldGRN]=True,"GREEN ","") AS Expr1
FROM MyTable;

If we're talking about something like colours in which a list of garments are available, I would recommend the Table Of Keys approach, this is where you have a table of possible colours 'TblPossCol' (each with an unique autonumber ID), a table of garments 'TblGarment '(also each with unique IDs) and a third table 'TOKGarmCol' (table of keys), each row describing one garment and one of it's available colours.

This way when a new colour is added to the range, it is just a matter of adding one row to TblPossCol for the new colour and one row to TOKGarmCol for each of the garments that will be available in the new colour.

Hope this helps

Mike

[This message has been edited by Mike Gurman (edited 01-19-2001).]

[This message has been edited by Mike Gurman (edited 01-19-2001).]

liner
01-19-2001, 04:23 AM
Thanks for your help Mike. When using a check box, how do I get the value to show "yes" instead of the default "-1" when the check box is selected?

Atomic Shrimp
01-19-2001, 05:05 AM
I assume you're talking about the appearance of the fields when displayed in a text box on a report?

You can set the Format property of the text box to either Yes/No On/Off or True/False, if the format property is left blank, it will display the values as -1/0

Mike

liner
01-24-2001, 07:11 AM
If I create a check box on a form and set the control source as an existing field in a table, how do I get the value in the table to be either "yes" or "no"? How do I set the properties for the check box control? Do I need to preset the properties of the field when creating the field in a table? Please advise. Thanks.