Date difference problem

J

Jono

I found and used S.Y.M. Wong-A-Ton's instructions for getting the difference
between two dates which worked perfectly. (
http://enterprise-solutions.swits.net/infopath/datediff-vbscript-infopath.htm
)
I then tried to get it to work in a repeating table but I keep getting this
error

A run-time error has occurred.
Do you want to debug?

The following error occurred:

'#PCDATA' is nil content:
<{http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-06-05T18:36:41}dateDiff>.

File:script.vbs
Line:75

Any ideas?
 
J

Jono

OK I just recreated the form and now it does the calculation with out the
error...but it will not do the calc. in subsequent lines in the repeating
table.

Is there any way to make this work in a repeating table?
 
J

Jono

I used the information in the article and it works as written. The problem I
have is, I want each line in the repeating table to do this calculation
seperatly. So I have a start date, end date and the interval, for that line
only, on each line.

As it is now I just get the total of all lines.
 
S

S.Y.M. Wong-A-Ton

I'm not sure I understand what you mean... Isn't it calculating the
difference per row now? Or is it that you want to calculate the total of all
the lines above and including the current line for each total field? If you
want to do the latter, you'll have to write a function to loop over all of
the total fields and calculate the grand total up to each total field for
each line. Then you can call this function in the OnAfterChange of all the
other non-total fields.
 
J

Jono

I found the problem I had a typo.

I do have another question. This form shows the Warranty End Dates for each
of our customers. In the startDate field I used the "Today" function and I
enter the last day of the customers warranty into the endDate field. This
then sets the "daysToExpiration" field value to the days left on the
warranty. I then use the conditional formatting to change the field color
based on how many days are left on the warranty.

What I'm wondering is will the "Today" function be updated every time I open
the saved form? So that as the each day passes the days left will count down.
 
S

S.Y.M. Wong-A-Ton

Good question! I've never tried it. However, I created a test form and saw
that it will not update the field when you set the Default value of the field
to today() and open a saved form. What does work however is if you add a rule
that will run when the form opens. So go to Tools > Form Options > Open and
Save tab and add a rule to set the value of your today field to the today()
function. The today field in all rows will be updated. Hope that's the
functionality you're after...
 

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