problems with adding repeating sections from 2nd data src using VB

T

TimPGade

FYI - My schema is at the end of this message.

I am trying to compose my Main xml from a secondary data source using VB
managed code and cannot find a way to add repeating members via code. I have
tried several/all of the suggestions I could find in this DG but am still not
having success.

Here is my problem.

In my form, I have a Repeating section (SectionChildren) with an Optional
section (SectionOptionalAMCodes) that has a Repeating table
(SectionChildAMCodes).

SectionChildren [RepeatingSection]
SectionOptionalAMCodes [Optional section]
SectionChildAMCodes [Repeating table]

In my load data, I have a household with multiple (0-many) children with
variations of the above data that I would like to add/insert into my xml and
and build into my form on AfterChange so the data is displayed.

I have an AfterChange event tied to a picklist dropdown that I use to fetch
external data into my Secondary and load it into my Main data source. I have
tried numerous suggestions from these threads to select and clone the
SectionChildren node and add the underlying elements to the clone and then
append the cloned node to the original node.

But I can't get any of them to work and I am sure I am overlooking something.

I have also tried the ExectueAction approach
thisXDocument.View.ExecuteAction("xCollection::insertAfter", "group18_55")
where group18_55 is the repeating SectionChildren.

I get this error message
System.Runtime.InteropServices.COMException
The specified bstrAction value for the View.ExecuteAction call is not
applicable for the current selection.
at Microsoft.Office.Interop.InfoPath.SemiTrust.View.ExecuteAction(String
bstrAction, Object varXmlToEdit)
at
Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.ExecuteAction(String bstrAction, Object varXmlToEdit)
at
Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.ExecuteAction(String bstrAction, Object varXmlToEdit)
at Form453.Form453.FormID_OnAfterChange(DataDOMEvent e)
at
Microsoft.Office.Interop.InfoPath.SemiTrust._DataDOMEventSink_SinkHelper.OnAfterChange(DataDOMEvent pDataDOMEvent)




<xsd:element name="SectionChildren">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="my:ChildName" minOccurs="0"/>
<xsd:element ref="my:SectionOptionalAMCodes" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ChildName">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="my:ChildFirstName" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ChildFirstName" type="xsd:string"/>
<xsd:element name="SectionOptionalAMCodes">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="my:SectionChildAMCodes" minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="SectionChildAMCodes">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="my:ChildAMCode" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ChildAMCode" type="xsd:string"/>
 
B

Brian Teutsch [MSFT]

You cannot change views during an onChage event. This is a limitation of
InfoPath. View changes must be tied to button clicks. Nothing at all to do
with your schema, just where you're calling SwitchView.

It's been hinted that you can use the OnContextChange event to call a
function in your task pane that switches the view, but I've not confirmed
this. It wouldn't be hard to try out.

Brian

TimPGade said:
FYI - My schema is at the end of this message.

I am trying to compose my Main xml from a secondary data source using VB
managed code and cannot find a way to add repeating members via code. I
have
tried several/all of the suggestions I could find in this DG but am still
not
having success.

Here is my problem.

In my form, I have a Repeating section (SectionChildren) with an Optional
section (SectionOptionalAMCodes) that has a Repeating table
(SectionChildAMCodes).

SectionChildren [RepeatingSection]
SectionOptionalAMCodes [Optional section]
SectionChildAMCodes [Repeating table]

In my load data, I have a household with multiple (0-many) children with
variations of the above data that I would like to add/insert into my xml
and
and build into my form on AfterChange so the data is displayed.

I have an AfterChange event tied to a picklist dropdown that I use to
fetch
external data into my Secondary and load it into my Main data source. I
have
tried numerous suggestions from these threads to select and clone the
SectionChildren node and add the underlying elements to the clone and then
append the cloned node to the original node.

But I can't get any of them to work and I am sure I am overlooking
something.

I have also tried the ExectueAction approach
thisXDocument.View.ExecuteAction("xCollection::insertAfter", "group18_55")
where group18_55 is the repeating SectionChildren.

I get this error message
System.Runtime.InteropServices.COMException
The specified bstrAction value for the View.ExecuteAction call is not
applicable for the current selection.
at Microsoft.Office.Interop.InfoPath.SemiTrust.View.ExecuteAction(String
bstrAction, Object varXmlToEdit)
at
Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.ExecuteAction(String
bstrAction, Object varXmlToEdit)
at
Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.ExecuteAction(String
bstrAction, Object varXmlToEdit)
at Form453.Form453.FormID_OnAfterChange(DataDOMEvent e)
at
Microsoft.Office.Interop.InfoPath.SemiTrust._DataDOMEventSink_SinkHelper.OnAfterChange(DataDOMEvent
pDataDOMEvent)




<xsd:element name="SectionChildren">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="my:ChildName" minOccurs="0"/>
<xsd:element ref="my:SectionOptionalAMCodes" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ChildName">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="my:ChildFirstName" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ChildFirstName" type="xsd:string"/>
<xsd:element name="SectionOptionalAMCodes">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="my:SectionChildAMCodes" minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="SectionChildAMCodes">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="my:ChildAMCode" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ChildAMCode" type="xsd:string"/>
 

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