# Checkboxes and n-m relationship puzzle

**URL:** <https://forum.servoy.com/t/checkboxes-and-n-m-relationship-puzzle/3065>\
**Category:** Classic Servoy\
**Created:** [November 16, 2004, 4:24am UTC](https://forum.servoy.com/t/checkboxes-and-n-m-relationship-puzzle/3065 "2004-11-16T04:24:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbonnett](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@dbonnett](https://forum.servoy.com/u/dbonnett)\
**Post date:** [November 16, 2004, 4:24am UTC](https://forum.servoy.com/t/checkboxes-and-n-m-relationship-puzzle/3065/1 "2004-11-16T04:24:31Z")

</div>

I have been struggling with trying to replicate a form I had in FMP, so far without success.

I have set up 3 tables as follows  
Grants-\>grant\_status-\>status  
where:

- grants is a list of activities (id is grant\_id) and is my primary table,
- status is a list of states that may apply to a grant (Emergency, Confidential, Donor Advised, On Hold),  
none of which are mutually exclusive (id is status\_id), and
- grant\_status is the n-m table holding grant\_id and status\_id to link them together. (id is grant\_status\_id)

I can get the appropriate status entries to show up in table form within a tabpanel (based on grant\_status),  
but I really want/need them to show up as a checkbox.  
So far, no matter what I try, I only see the first value in the grant\_status table for a given grant\_id,  
i.e. if both “Confidential” and “Donor Advised” are marked in the grant\_status table, only “Confidential” will be checked.  
The SQL looks fine, based on what I can see from a stacktrace; running it gives me the right rows, but no go on the interface.

I don’t really want to go to a calculated field since I need to have this be searchable; the same holds for html  
(unless that can be made to work as a search field)  
I would love some guidance on this, since my client will be very irked to lose this functionality.

Thanks.  
(Servoy 2.1.1 W2K, Java 1.4.2\_04)

---

<div class="post-metadata">

**Author:** ![dbonnett](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@dbonnett](https://forum.servoy.com/u/dbonnett)\
**Post date:** [November 20, 2004, 12:56am UTC](https://forum.servoy.com/t/checkboxes-and-n-m-relationship-puzzle/3065/2 "2004-11-20T00:56:07Z")

</div>

Since no one has offered even a comment, I will follow up myself.

So far, I am finding working with checkboxes to be  
a HUGE source of frustration.  
Using checkboxes to store more than one value  
for each record works fine in other apps (including  
our whipping boy Filemaker), but making this work  
in Servoy seems to be damn near impossible.  
Following Johan’s suggestion, I went to a n-m approach  
(as described above), but I have to use a calculated  
field to have more than one value displayed (checked).  
Of course, this screws the chance of doing searches,  
since I am then back to having concatenated strings  
in the calculation and wildcard matches don’t work.  
In addition, I have to go override the find method to  
do this, so I lose the ability to search on the rest of  
the fields (as far as I can tell, since I have to go into  
find mode, but I don’t have a way to pick up when  
the user hits enter to actually do the search.

Can anyone tell me the value of checkboxes in Servoy?  
The documentation on them is pretty thin (do a search  
in any of the docs and find lots of mentions of “checking  
the checkbox” for some option, but very little on how to  
manage them in your own interface). Why do I have to  
go through all of these contortions to make them work  
as the users expect???

Excuse the venting, but I have been fighting with these  
for over a week and so far have not made any real  
progress. I would assume others are not trying to use  
checkboxes for multiple values since no one has offered  
any suggestions or comments.

---

<div class="post-metadata">

**Author:** ![maarten](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@maarten](https://forum.servoy.com/u/maarten)\
**Post date:** [November 21, 2004, 8:16pm UTC](https://forum.servoy.com/t/checkboxes-and-n-m-relationship-puzzle/3065/3 "2004-11-21T20:16:45Z")

</div>

It is possible to do this with an n-m table but here’s a sample solution using another approach.  
It basically does following:

1. uses a global to capture the search criteria(popup dialog with all checkboxes)
2. converts content of the global into an array of the marked selections
3. loops through the array, creating find requests  
(this would be an OR find, but you could make it more flexible using direct queries with filters that can be set by user in the popup dialog)

No need to create an n-m table.  
Let me know if this would fit in into your conversion.

NB:  
-for simplicity I’ve put the status in a custom valuelist  
(but of course you can use a table instead)

- please add some records(Ctrl+N) yourself. (there’s no data in the sample solution)
- use (Ctrl+F) to pop up the search box.
