Setting a Date Picker control with a rule as Text produces error - InfoPath Dev
in

InfoPath Dev

Setting a Date Picker control with a rule as Text produces error

Last post 03-29-2013 06:08 AM by ErnestoM. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-28-2013 01:40 PM

    • AlexK
    • Top 200 Contributor
    • Joined on 12-31-2012
    • Posts 61

    Setting a Date Picker control with a rule as Text produces error

    I have a Date Picker where I need to set its year with a rule based on a dropdown of years, similar to this: http://www.bizsupportonline.net/blog/2009/04/pre-select-year-infopath-date-picker-control/

    Using substrings to get the day and month, I manually set the Date Picker using the formula: concat(number(substring(datePicker, 6, 2)), "/", number(substring(datePicker, 9, 2)), "/", yearSelection)

    This only works halfway, though. It seems InfoPath does not like its Date Picker to be set as text. When the rule runs once, it's fine and properly sets the control to show with the new year, day and month with slashes intact.

    BUT, when I select another year and the rule runs again, it populates the Day and Month with junk numbers (or NaNs) and highlights the control red because it thinks it is not a date type. Is there a way in my rule to convert the string as a date type to work around this? Or this is another problem altogether?
  • 03-29-2013 06:08 AM In reply to

    Re: Setting a Date Picker control with a rule as Text produces error

    You may have a data type issue. As the article states:

    Depending on whether your date picker control is set to accept dates or dates and times, you must use the appropriate date format when entering the dates for the years. Here, my date picker control accepts only dates, so I used 1995 as the Display name and 1995-01-01 as the Value when adding an entry for the year 1995 to my drop-down list box.

    Another option might be: if the user changes the Year dropdown, you first clear the DatePicker control (set it to blank), and then run the rest of the rules. This guarantees that every time the rules execute, they are running in the same scenario: a blank DatePicker.

    Good luck.

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


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