Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

The date is not parsed correctly when you set the date by using a rule in InfoPath 2007


View products that this article applies to.

Symptoms

When you set a date by using a rule in Microsoft Office InfoPath 2007, the date is not parsed correctly. Additionally, the date field displays a red, dashed border that indicates that the value is not valid.

↑ Back to the top


Cause

This behavior occurs because the date must be in the YYYY-MM-DD format when you set the date by using a rule or by using code. If the date is not in this format, the date is not parsed correctly, and the date is displayed as a value that is not valid.

↑ Back to the top


Workaround

To work around this behavior, use a date that is in the YYYY-MM-DD format when you set the rule. To do this, follow these steps:
  1. Start InfoPath 2007, click Design a Form Template, select Blank, and then click OK.
  2. Click Controls, and then add a Text Box control to the left pane. The default name of this field is field1.
  3. Double-click the text box, select Date (date) in the Date type drop-down list, and then click OK.
  4. Click the Format button.
  5. Select the format, for example 3/14/2001, and then click OK.
  6. Click OK one more time.
  7. Add a Button control to the left pane. The default name of this control is Button.
  8. Double-click Button, click Rules, and then click Add.
  9. Click Add Action, select Set a field's value in the drop-down list.
  10. Click the icon that is next to the Field text box, and then select field1.
  11. Type a validate format date, for example 2006-09-30, and then click OK.
  12. Click OK three times.
  13. Click Preview on the toolbar, and then click Button. You will see 9/30/2006 shown in the date field.

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


More information

Steps to reproduce the behavior

  1. Start InfoPath 2007.
  2. Click Design a Form Template, click Blank, and then click OK.
  3. Click Controls, and then add a Text Box control to the left pane.

    By default, the name of this control is field1.
  4. Double-click field1, click Date (date) in the Date type list, and then click OK.
  5. Add a Button control to the left pane.

    By default, the name of this control is Button.
  6. Double-click Button, click Rules, and then click Add.
  7. Click Add Action, and then click Set a field's value.
  8. Click the icon that is next to the Field box, and then click field1.
  9. Type a date in a format that is not valid, and then click OK.

    For example, type 9/30/06, and then click OK.
  10. Click OK three times.
  11. On the toolbar, click Preview, and then click Button.

↑ Back to the top


Keywords: KB924727, kbprb, kbtshoot, kbexpertiseinter

↑ Back to the top

Article Info
Article ID : 924727
Revision : 4
Created on : 11/3/2006
Published on : 11/3/2006
Exists online : False
Views : 319