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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a list of values from checkboxes

Status
Not open for further replies.

ltidquist

MIS
Sep 28, 2007
45
US
I am using CR 9.0.

I have a database that has a table with a number of checkboxes to indicate a company's region or regions. I have created formulas for each checkbox to print the name of the region (ie North America). I now need to create a comma-separated list of the regions they have checked.

Can anyone help me with this?
Thanks in advance.
 
Yes, but it would help to see the content of the name formula. Also, please explain whether you want this list per some group (company?).

-LB
 
Yes, it would be based on a group called Alpha, which just groups by company name.

Thanks.
 
Basically, I created a formula for each checkbox to print the name of it:

@Region_Asia
if {Regions.Asia}=True then 'Asia' else ''

I have about 10 more of those.

I want to be able to list them separated by commas.

Hopefully that's what you're asking.

Thanks.
 
Are you saying that each region is actually a separate field, not a separate instance of one field? If they really are separate fields, e.g., {Regions.Europe},{Regions.Asia}, {Regions.Pacific}, then can you confirm that there is no overlap in regions, i.e., that in one row of data only one region is true?

-LB
 
I have one table called Regions. In that table I have the following boolean (checkbox) fields:

Asia
Australia
Canadian Territories
Central America
China
East North Central
East South Central
Eastern Canada
European Union
Mexico
Middle Atlantic
Mountain
New England
Pacific
Puerto Rico
South America
South Atlantic
West North Central
West South Central
Western Canada

For each company in the database they can have any number of these boxes checked. I need comma separated list of which ones they have selected.

Thanks so much for helping me.
 
I think you can create one large formula like this:

stringvar x := "";
x :=
(
if isnull({Regions.Asia}) or
{Regions.Asia} = false then
"" else
"Asia, "
) +
(
if isnull({Regions.Australia}) or
{Regions.Australia} = false then
"" else
"Australia, "
) +
//etc.
; left(x,len(x)-2)

I'm not sure whether the field can be true or null or just true or false, probably the latter, so you can probably omit the isnull() clause in each segment.

-LB
 
Well, I think I'm getting closer. I don't get any errors in the formula but when I generate the data for the report I get the following error:

String length is less than 0 or is not an integer.

Any ideas?

Thanks.
 
Did you use comma+space in each section? Could any companies not have any regions = true? I assumed that the fields would be populated in the same row, too.

Try changing the following to:

if len(x)>2 then
left(x,len(x)-2) else
x

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top