Insert control into DB query section

K

Kevin M

Hi all. I have been having a horrible time with this. Hope someone
can help me.

I am trying to add a checkbox to a repeating section that is being
populated by a database query. This is necessary, since I need a way
for the user to tell me which items s/he needs.

I have the query in place, and it populates beautifully with 2 nested
repeating sections (one for each table I'm pulling data from).
However, when I try to add a checkbox to either section, InfoPath
requires me to select an existing data source item. So I created a
basic Boolean field. But when I try to bind the checkbox to this
field, I get the following error: "You have chosen to bind a
non-repeating control to a repeating field or group. This control
will be bound to the first item in the repeating field or group.
<linebreak> Do you want to continue? <Yes/No>"

I have removed the check from the "repeating" box of the data field.
And this removes the error message noted above. However, when I do it
like this, checking off one of the boxes in the populated list
triggers all of the checkboxes. Meaning that if I check off Item A,
all of the checkboxes on the whole form get checked.

Please help me, if you can. I am running InfoPath with SP1 and the
developer's toolkit both installed.
 
A

Andrew Watt [MVP - InfoPath]

Kevin,

I suspect that you are getting controls which are bound to query
fields tangled up with controls which are bound to data fields.

If you separate more clearly on the form (perhaps using a separate
view) the notions/actions of querying and displaying returned data I
think you will find things easier.

Andrew Watt
MVP - InfoPath
 
J

jb

*Where* have you created your "basic Boolean field"? You have to create it
as a field in the row, so each row has its own value.
 
K

Kevin M

Thanks to the both of you. I ended up speaking with a coworker, and
we sorted it out. I will explain how to aid future developers....

1. I opened my Data Connections and modified the actual SQL query and
added another field to the select portion.

2. However, since my DB table did not have any column that
corresponded, I made up a new name. By assigning a default value to
this "column", I avoided problems. So, since I wanted my checkboxes
unchecked by default, I made the default value in the query be 0
(zero).

Hence: "Select "made_up_field"=0, ..."

3. Then I added a checkbox to the repeating section that was being
populated by the DB query. When it asked me which field to bind to, I
picked the field I just made (made_up_field).

4. One last problem (bug, IMHO) was that InfoPath decided that this
control should have both its OnValue and OffValue attributes set to
the empty string. Meaning that checking it on and off did not change
the value. Meaning no event generation and therefore no ability to
react to the clicks (nor "see" which boxes are checked
programmatically).

5. So I closed InfoPath and (thanks to Microsoft's InfoPath developer
kit which integrates InfoPath and Visual Studio .NET) went to the
project in VS. I found the file with the same name as the View
containing the control and opened it. I changed the "OnValue"
attribute of the new checkbox control to be 1 (one) and the "OffValue"
to be 0 (zero).

Voila! The events fire and each entry of the repeating section has
its own checkbox that keeps its own state. C'est magnifique!

Thanks again for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top