Default State on Some Check Boxes Not Maintained in an Optional Section - InfoPath Dev
in

InfoPath Dev

Default State on Some Check Boxes Not Maintained in an Optional Section

Last post 07-12-2010 09:25 PM by cbrown00. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 07-02-2010 11:36 PM

    Default State on Some Check Boxes Not Maintained in an Optional Section

    I have 7 check boxes in an optional section control.  I want the default state on all to be "checked".  The "value when checked" setting is populated for each check box control.  The "value when cleared" setting is blank.  After setting the default state in design mode, when I preview the form, the default state shows "checked" as it was set. However, when I save the form and re-open in design mode again, the default state reverts to "clear".  Is there some setting I need to make in the Optional Section control to make sure the check boxes retain their "checked" state?  Strange that one would retain it, and the others would not.  I see no difference in their configuration settings.

     

  • 07-05-2010 11:16 PM In reply to

    Re: Default State on Some Check Boxes Not Maintained in an Optional Section

     can you attach the template, it certainly seems to be strange

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 07-07-2010 08:50 AM In reply to

    Re: Default State on Some Check Boxes Not Maintained in an Optional Section

    Qazi, file attached.  Blue section contains numerous check boxes, some of them retain desired default status (i.e, checked); the others will not.  I would like them all to be default "check" status.

  • 07-12-2010 06:31 AM In reply to

    Re: Default State on Some Check Boxes Not Maintained in an Optional Section

    cbrown00, your form seems to be acting strange, i took a cursory look at it but couldnt find out the reason for such type of behaviour. i will try to get some time tomorrow and look at it properly and let you know my inputs. 

     

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 07-12-2010 07:21 AM In reply to

    Re: Default State on Some Check Boxes Not Maintained in an Optional Section

    The problem is that you have a space at the end of several of the Checked values.  When the XSN is saved, these spaces are truncated from the default values, and this causes the field values to not match the Checked values of the checkboxes, and they are resultingly treated as unchecked.

    I think I can see why you want to have spaces at the end, but I don't think your design is going to work as-is.  Removing the spaces will fix the problem, but if you must have them, attached is a form that shows how you can accomplish the same thing, using Boolean fields bound to the checkboxes, and separate fields to contain the actual text.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-12-2010 07:39 PM In reply to

    Re: Default State on Some Check Boxes Not Maintained in an Optional Section

    Very interesting.  Thanks!

    Looking at the alternative approach you provided that uses Boolean fields, I have a question about the formula in the second field copied below:

                    substring("Field 1 is checked ", 5000 * (../my:field1 = "false"))

    I'm still learning programming in InfoPath.  It looks like this approach uses a conditional "if" argument in field 2, but I don't see how it's done.  What does the "5000 * (../my:field1="false")" specify here in the second argument for this command?

  • 07-12-2010 09:22 PM In reply to

    Re: Default State on Some Check Boxes Not Maintained in an Optional Section

    It uses a trick that in a multiplication expression, (../my:field1 = "false") will be treated as the value 1 when my:field1 is false, and 0 otherwise.  This is then multiplied by 5000, so it boils down to this:

    field1 is not false:

    substring("Field 1 is checked ", 0)

    field1 is false:

    substring("Field 1 is checked ", 5000)

    In the first case, the substring function returns the value of the string from character 0 (the beginning) through the end, resulting in the whole string.

    In the second case, the result is the substring of the string starting from character 5000 through the end.  Since the string is not 5000 characters long, the result is an empty string.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-12-2010 09:25 PM In reply to

    Re: Default State on Some Check Boxes Not Maintained in an Optional Section

    Great...thx Jimmy for the explanation!  Big help for me.

Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.