Auto Date Calculation

  • Thread starter Luke Slotwinski
  • Start date
L

Luke Slotwinski

In designing a form I have a Date Picker field to choose Date Received.
I would like to create a field which would Auto insert a date that is Date
Received +10 days. Example... if Date Received was 11/10/06 I want the
field Date Due to auto insert 11/20/06.

Thank you,
Luke Slotwinski
 
S

S.Y.M. Wong-A-Ton

If you are using InfoPath 2007, you can use the built-in "addDays" function
to do this. If you're using InfoPath 2003, you'll have to code it yourself.
Search this newsgroup on "add days" to find samples on how to do this.
 
L

Luke Slotwinski

Wong-A-Ton:
I am in InfoPath 2003... I searched the newsgroup but could not find exactly
what im looking for. I found
http://www.microsoft.com/office/com...b30843-25b5-4da3-a3f3-1e08183237b7&sloc=en-us
; which is close to what I need. I have a field rcv_date and want the next
field due_date to be +10 days from rcv_date. The examples listed under the
two URL's you posted to that reply do not show how to link it to another
field. If I create the function..

function addtendays()
{
dtNextWeek = new Date();
dtNextWeek.setDate( dtNextWeek.getDate()+10 );
alert( dtNextWeek );
}

Where do I put this function? And how can I get it to bind to due_date field?

Luke Slotwinski
 
R

Russ

You can call that function from within the OnAfterChange event handler for
the rcv_date field. Add the OnAfterChange event handler by locating the
field in your form's data source, double click, select "validation and event
handlers" tab, select OnAfterChange from the events box, click edit.

Then you'll need to update the due_date field with the new date, which you
can do:

xmlDueDate = XDocument.DOM.selectSingleNode(xpath to due_date)
xmlDueDate.text = dtNextWeek

Something like that should work.
 

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