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.

Autopopulating a Repeating Section

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BethA - 10 Nov 2005 19:58 GMT
I am plugging away at autopopulating some fields of a repeating section
(including BriefDescription) given an item number, using the OnAfterChange
event for the item number. I started out using a secondary data source (a
view on SQL server) and couldn't get that to work, but got some help with
using ADO.net to access SQL server and get the data I need.

It works great for the first item in the section, but when a second item is
added, the fields in the first item are populated instead of in the second
item. That's exactly what I was telling it to do since I accessed the nodes
in this way:

Dim fDescNode As IXMLDOMNode =
thisXDocument.DOM.selectSingleNode("/my:myFields/my:RequestedSample/my:BriefDescription")

So every time it is getting the first node in the repeated section. How do I
tell it to get the node which matches the ItemNumber that has just been
updated?

I hope this makes sense, because I'm learning XML as I go along!

Another question that just came up is: why doesn't my event handler happen
when I publish the form and fill it in from the published form? It works when
I'm previewing in InfoPath.

Thanks,
BethA            
Franck Dauché - 10 Nov 2005 20:05 GMT
Hi Beth,

You can target the nth item in your section using code such as:
IXMLDOMNode oNode =
thisXDocument.DOM.selectSingleNode("/my:myFields/my:group1/my:group2[n]/my:field1");

Hope that it helps.

Regards,

Franck Dauché

> I am plugging away at autopopulating some fields of a repeating section
> (including BriefDescription) given an item number, using the OnAfterChange
[quoted text clipped - 22 lines]
> Thanks,
> BethA            
BethA - 10 Nov 2005 20:09 GMT
How do I tell what n is, given that I know which node triggered the event,
but not where it is in the group?

Thanks,
BethA

> Hi Beth,
>
[quoted text clipped - 34 lines]
> > Thanks,
> > BethA            
Franck Dauché - 10 Nov 2005 20:21 GMT
Hi Beth,

Why don't you loop through your nodes and put the values that you need:
IXMLDOMNodeList oNodeList =
thisXDocument.DOM.selectNodes("my:myFields/my:group1/my:group2");
if (oNodeList.length>0)
{
 foreach (IXMLDOMNode oN in oNodeList)
 {
   if( oN.nodeType == DOMNodeType.NODE_ELEMENT )
   {
     IXMLDOMNode oField = oN.selectSingleNode("my:field1");
     oField.text = "test";  //<-- Put your value here
   }
 }
}

Regards,

Franck Dauché

> How do I tell what n is, given that I know which node triggered the event,
> but not where it is in the group?
[quoted text clipped - 40 lines]
> > > Thanks,
> > > BethA            
BethA - 11 Nov 2005 16:15 GMT
Thanks Franck - It works! I just had to add a condition to the if statement
to make sure that the refNumber field of the oNode matched the refnumber that
caused the OnAfterChange event to occur. I'm not sure if I need the
oNode.nodeType = DOMNodeType.NODE_ELEMENT part because it seemed that every
node had that nodeType.

I think the problem with the published form not working was because it was
published on the network. Everything seems to work fine from my hard drive.
That's a question we have to talk about next week with CIS :-)

BethA

> Hi Beth,
>
[quoted text clipped - 61 lines]
> > > > Thanks,
> > > > BethA            
BethA - 11 Nov 2005 16:19 GMT
I was wrong - the published form doesn't autopopulate, even when published to
my hard drive! Any ideas? Maybe I'll post a new question just about that!

BethA

> Hi Beth,
>
[quoted text clipped - 61 lines]
> > > > Thanks,
> > > > BethA            
 
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.