Dynamic months - InfoPath Dev
in

InfoPath Dev

Dynamic months

Last post 06-24-2010 04:19 AM by Sam Spritzer. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 06-23-2010 08:14 AM

    Dynamic months

    I have an Infopath (2007, SP2) form that looks like a spreadsheet.  It is designed to allow users to enter number of hours across the spreadsheet.  Each column represents a month and there will be up to 24 months.  I have been looking high and low for any rules or logic which will allow me to display today() as mm/yy and then increment each column by one mm/yy.  I am not an experienced InfoPath programmer by any stretch of the imagination so I am considering this as part of my learning experience.  Thanks in advance.

  • 06-23-2010 02:12 PM In reply to

    I don't know if there is a way without code for this, but if you're willing to do this with code, here is an exemple :

    First create an On_Load event (if you do not want this to be on form load, then any other event will work too)

    Here's the "code" you should be using in the event :

    XPathNavigator root = MainDataSource.CreateNavigator();
    DateTime todaysDate = DateTime.Today.ToString("d");
    Int day = todaysDate.Day;
    Int Month = todaysDate.Month;
    Int Year = todaysDate.Year;
    for each column you want to populate
    {
              Month++;
              DateTime newDate = New DateTime(day, Month, Year);
              root.SelectSingleNode("your filed", Namespacemanager).SetValue(newDate.ToString());
    }

     

    Notice this is not the exact code to use, but it will be somehow like that. This is an algorithm.

    Hope this help!

  • 06-24-2010 04:19 AM In reply to

    Thanks so much, mgarant.  I was afraid I would have to resort to code.  So now, I am thinking of a function that allows me to do this but defining a field as where can specify month plus 1.

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