Big Problem #4: Checking a Checkbox State

S

Shemp

This one is more generic:

Create a doc with two text fields (txtField1 and txtField2) and a
checkbox. What I want is, if the checkbox is checked, the value of
txtField1 goes into txtField2.

My conundrum comes from not knowing how to determine whether the
checkbox is checked. If I go into Rules on txtField2 and click
Condition, the first box points to the check box, and the second box is
where I get confused. I'm looking for "is selected" or something like
that, but the closest I can get is "is not blank" which doesn't work.

Clearly I'm missing something here, or not understanding how InfoPath
works, but dogged if I know.
 
C

Cillian

If you open the check box properties, you will see the vale given to the
control when it is check and unchecked.
 
S

Scott L. Heim [MSFT]

Hi Jeff,

Here are some sample steps that appear to work as you need:

- Create a new, blank InfoPath form
- Add 2 text boxes (field1 and field2) and a checkbox (field3)
- Right-click on the check box and choose Properties
- Click the Rules button
- Click Add
- Click the Set Condition button
- In the first drop down, choose field3
- In the second drop down, choose "is equal to"
- In the third drop down, choose TRUE and then click OK
- Click the Add Action button
- Click Set a field's value from the Action box
- Click the select a field or group button next to Field and choose field2
- Click the Insert Formula button next to Value and choose field1
- Click OK until you are back to your form
- Test

Now if you want the field to be cleared out if the check box is unchecked,
then complete the same basic steps above by adding a new rule where the
condition is the check box is "FALSE" and simply leave the "Value" field
blank.

I hope this helps!

Best Regards,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Shemp

Thanks, I will try that.

To be more specific, what I an wanting to do is have several fields
under the heading "Billing Address". Next to that is an optional
section for "Shipping Address" with a checkbox that says, "Same as
Billing Address." If this is checked, automagically populate the
corresponding fields under Shipping Address (Name, Address, City, ST,
ZIP etc.) that exist under Billing Address. So, if the shipping
address is same as billing, I check a checkbox and it all fills in for
me.

Thanks again!
 
S

Scott L. Heim [MSFT]

Hi Jeff,

That is certainly doable - you can simply use "Rules" where the action is
to set a field's value and then have a condition on the rule such that it
only fires if the checkbox is true.

I hope this helps!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Shemp

OK, so I have a new blank form with textboxes txtA and txtB, and a
checkbox next to txtB labled "same as A". If the checkbox is checked,
whatever's in A goes into B, and that works as advertised.

I've created a rule for the checkbox that says, "If my value is TRUE,
set the value for txtB = txtA" and that works fine. If I uncheck the
checkbox, though, it doesn't clear txtB. Do I have to make another
rule for that condition?
 

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