Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / November 2005

Tip: Looking for answers? Try searching our database.

Calculating a repeating table column with VB.NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Doug H. - 15 Nov 2005 21:18 GMT
I am using managed code for InfoPath to sum the diff. between two dates and
displaying the "number of days" in the repeating column.  The code works fine
on the first row only.  If I add a new row the number of days is blank.  "the
code fires in debug" but it doesn't use the current selected row node.

How can I sum a column in a repeating row using VB.NET?

Sample LINE:
thisXDocument.DOM.selectSingleNode("/my:myFields/my:Request_Types/my:Request_Type/my:TotalDays").text
= DateDiff("d",
CDate(thisXDocument.DOM.selectSingleNode("/my:myFields/my:Request_Types/my:Request_Type/my:RequestFromDate").text),
CDate(thisXDocument.DOM.selectSingleNode("/my:myFields/my:Request_Types/my:Request_Type/my:RequestToDate").text)) + 1

Thanks,
Doug
Franck Dauché - 15 Nov 2005 22:15 GMT
Hi Doug,

Where is that code located?

If you have a button on each row to do the calculation, you need to use:
IXMLDOMNode oField1 = e.Source.selectSingleNode("my:RequestFromDate");
IXMLDOMNode oField2 = e.Source.selectSingleNode("my:RequestToDate");

If instead, you are calling that code from the OnAfterChange in one of the 2
dates, use:
IXMLDOMNode oNode = e.Site.selectSingleNode("..");
IXMLDOMNode oField1 = oNode.selectSingleNode("my:RequestFromDate");
IXMLDOMNode oField2 = oNode.selectSingleNode("my:RequestToDate");

Hope that it helps.

Regards,

Franck Dauché

> I am using managed code for InfoPath to sum the diff. between two dates and
> displaying the "number of days" in the repeating column.  The code works fine
[quoted text clipped - 11 lines]
> Thanks,
> Doug
Doug H. - 16 Nov 2005 12:58 GMT
Franck, Thanks for the response, but I must be doing something wrong.
I added the following code you mentioned and it still updates the first row
only.  Yes, this gets fired during the onafterchange event.  Should I use an
index number in place of the e.Site.selectSingleNode("..")?

               Dim oNode As IXMLDOMNode = e.Site.selectSingleNode("..")
               Dim oField1 As IXMLDOMNode =
oNode.selectSingleNode("/my:myFields/my:Request_Types/my:Request_Type/my:RequestFromDate")
               Dim oField2 As IXMLDOMNode =
oNode.selectSingleNode("/my:myFields/my:Request_Types/my:Request_Type/my:RequestToDate")
               
oNode.selectSingleNode("/my:myFields/my:Request_Types/my:Request_Type/my:TotalDays").text = DateDiff("d", CDate(oField1.text), CDate(oField2.text)) + 1

Doug

> Hi Doug,
>
[quoted text clipped - 31 lines]
> > Thanks,
> > Doug
Franck Dauché - 16 Nov 2005 14:38 GMT
Hi Doug,

Look at my original post, for oField1, the XPath is: my:RequestFromDate, not
the full: /my:myFields/my:Request_Types/my:Request_Type/my:RequestFromDate
Same for oField2.  In fact the full XPath on oNode, should not work at all.

Let me explain: you start from the event, wherever you are in the section.  
By selecting "..", you go up one level in your schema to Request_Type.  Form
there, you go back to RequestFromDate (the right instance).

Hope that it helps.  If my post was useful, don't forget to rate it.

Regards,

Franck Dauché

> Franck, Thanks for the response, but I must be doing something wrong.
> I added the following code you mentioned and it still updates the first row
[quoted text clipped - 46 lines]
> > > Thanks,
> > > Doug
Doug H. - 17 Nov 2005 14:31 GMT
Thanks it worked, my mistake.

Doug

> Hi Doug,
>
[quoted text clipped - 62 lines]
> > > > Thanks,
> > > > Doug
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.