Have problems sending data from one repeating table to another. - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Have problems sending data from one repeating table to another.

Last post 05-31-2013 02:21 PM by Hilary Stoupa. 42 replies.
Page 2 of 3 (43 items) < Previous 1 2 3 Next >
Sort Posts: Previous Next
  • 05-25-2013 03:14 PM In reply to

    Re: Have problems sending data from one repeating table to another.

    I am still in need of some serious help, please. The code listed above copies my data from a secondary data source  repeating table(PartsList) to another repeating table (PartsListUpdate)

    For all of the code experts out there, can you please help me with the code to get the information from the (PartsListUpdate) repeating table to a repeating table called (POG_InfoPath_MasterFile).

    The table is an Access Database "main connection" with rerieve and submit functions.

    I have been stuck and am not making any progress on this and I am scheduled to provide a demo with the Directorate VP.  Please help.

    Thank you. 

     

  • 05-28-2013 07:56 AM In reply to

    Re: Have problems sending data from one repeating table to another.

     Well - wouldn't the code be similar? I don't really understand what the issue is. You are currently successfully copying data from one data source to another with your code? But you can't modify the code to copy to the main data source?

    Hilary Stoupa

  • 05-28-2013 10:52 AM In reply to

    Re: Have problems sending data from one repeating table to another.

    Hilary,

    I have tried to modify the code without success.  At this point, I don't know if I am missing some "small" detail. This code works from 1 table to the other:

    Public Sub CTRL174_23_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

                Dim Nav As XPathNavigator = Me.DataSources("PartsList").CreateNavigator()
                Dim rows As XPathNodeIterator = Nav.Select("/dfs:myFields/dfs:dataFields/d:PartsList", NamespaceManager)

                While rows.MoveNext()

                    Dim PartNumb As String = rows.Current.SelectSingleNode("@PartNumb", NamespaceManager).Value
                    Dim PartDesc As String = rows.Current.SelectSingleNode("@PartDesc", NamespaceManager).Value
                    Dim Color As String = rows.Current.SelectSingleNode("@Color", NamespaceManager).Value
                    Dim OracleNmbr As String = rows.Current.SelectSingleNode("@OracleNmbr", NamespaceManager).Value
                    Dim RevitNme As String = rows.Current.SelectSingleNode("@RevitNme", NamespaceManager).Value
                    Dim Catg As String = rows.Current.SelectSingleNode("@Catg", NamespaceManager).Value
                    Dim CSPK As String = rows.Current.SelectSingleNode("@CSPK", NamespaceManager).Value
                    Dim Selecta As String = rows.Current.SelectSingleNode("@Select", NamespaceManager).Value

                    If Selecta = "True" Then
                        Try

                            Dim node As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode( _
                            "/dfs:myFields/my:Contain/my:PartsListUpdate", NamespaceManager)

                            DeleteNil(node)

                            Dim myNamespace As String = NamespaceManager.LookupNamespace("my")
                            Using writer As XmlWriter = MainDataSource.CreateNavigator().SelectSingleNode( _
                            "/dfs:myFields/my:Contain", NamespaceManager).AppendChild()
                                writer.WriteStartElement("PartsListUpdate", myNamespace)
                                writer.WriteElementString("PartNumb", myNamespace, PartNumb)
                                writer.WriteElementString("PartDesc", myNamespace, PartDesc)
                                writer.WriteElementString("Color", myNamespace, Color)
                                writer.WriteElementString("OracleNmbr", myNamespace, OracleNmbr)
                                writer.WriteElementString("RevitNme", myNamespace, RevitNme)
                                writer.WriteElementString("Catg", myNamespace, Catg)
                                writer.WriteElementString("CSPK", myNamespace, CSPK)
                                writer.WriteEndElement()
                                writer.Close()
                            End Using

                        Catch ex As Exception
                            MessageBox.Show(ex.Message)
                        End Try
                    End If
                End While
            End Sub

     Now I would like to go from the "/dfs:myFields/my:Contain/my:PartsListUpdate" table to the "/dfs:myFields/dfs:dataFields/d:POG_MasterList_InfoPath".  What am I missing?

    Thank you - Chad

  • 05-28-2013 10:55 AM In reply to

    Re: Have problems sending data from one repeating table to another.

     My guess would be that starting from here:

     If Selecta = "True" Then

    You'd need to change your XPaths and your namespace. What have you tried?

     

    Hilary Stoupa

  • 05-28-2013 11:10 AM In reply to

    Re: Have problems sending data from one repeating table to another.

    Hilary, Thank you.  I have taken this apart piece by piece.  I have just tried:

    Public Sub CTRL1334_9_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

                Dim Nav As XPathNavigator = Me.DataSources("PartsListUpdate").CreateNavigator()
                Dim rows As XPathNodeIterator = Nav.Select("/dfs:myFields/my:Contain/my:PartsListUpdate", NamespaceManager)

                While rows.MoveNext()

                    Dim PartNumb As String = rows.Current.SelectSingleNode("@PartNumb", NamespaceManager).Value
                   
                    Try

                        Dim node As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode( _
                        "/dfs:myFields/dfs:dataFields/d:POG_MasterList_InfoPath", NamespaceManager)

                        DeleteNil(node)

                        Dim myNamespace As String = NamespaceManager.LookupNamespace("my")
                        Using writer As XmlWriter = MainDataSource.CreateNavigator().SelectSingleNode( _
                        "/dfs:myFields/dfs:dataFields", NamespaceManager).AppendChild()
                            writer.WriteStartElement("d:POG_MasterList_InfoPath", myNamespace)
                            writer.WriteElementString("PartNumb", myNamespace, PartNumb)
                           
       writer.WriteEndElement()
                            writer.Close()
                        End Using

                    Catch ex As Exception
                        MessageBox.Show(ex.Message)
                    End Try
                    'End If
                End While
            End Sub

     And got this nice error message:

     System.Runtime.InteropServices.COMException
    An item with the following index does not exist in the collection: PartsListUpdate
       at Microsoft.Office.Interop.InfoPath.SemiTrust.DataObjects.get_Item(Object varIndex)
       at Microsoft.Office.Interop.InfoPath.SemiTrust.DataObjectsCollectionWrapper.get_Item(Object varIndex)
       at Microsoft.Office.InfoPath.Internal.DataSourcesHost.get_Item(String name)
       at Bridge_22Apr13.FormCode.CTRL1334_9_Clicked(Object sender, ClickedEventArgs e)
       at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
       at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

  • 05-28-2013 11:18 AM In reply to

    Re: Have problems sending data from one repeating table to another.

    Does the empty row at the top of the "copy from" (PartsListUpdate) table make a difference?

  • 05-28-2013 11:28 AM In reply to

    Re: Have problems sending data from one repeating table to another.

     That error message tells you this line is wrong:

    Dim Nav As XPathNavigator = Me.DataSources("PartsListUpdate").CreateNavigator()

    Bolded the issue - what is the actual name of the data source?

    Do you know how to run your code in debug so you can walk through this while it is running?

    Hilary Stoupa

  • 05-28-2013 11:45 AM In reply to

    Re: Have problems sending data from one repeating table to another.

    The complete xpath is "/dfs:myFields/my:Contain/my:PartsListUpdate".  This is not a data connection, it is the repeating table (PartsListUpdate) that receives the data from the (PartsList) repeating table.

  • 05-28-2013 11:57 AM In reply to

    Re: Have problems sending data from one repeating table to another.

     The error is:

    An item with the following index does not exist in the collection: PartsListUpdate

    This indicates you are referencing a data source incorrectly.

    It would appear that this line is throwing the error:

    Dim Nav As XPathNavigator = Me.DataSources("PartsListUpdate").CreateNavigator()

    Do you see how you are trying to get the PartsListUpdate data source above?

    DataSources("PartsListUpdate")

    Is the name of the data source you are trying to access "PartsListUpdate"?

    Hilary Stoupa

  • 05-28-2013 12:02 PM In reply to

    Re: Have problems sending data from one repeating table to another.

     Or perhaps you are trying to access data in the main data source? Is that the case? In which case you would use something like:

    Dim Nav As XPathNavigator = Me.MainDataSource.CreateNavigator()

    Hilary Stoupa

  • 05-28-2013 12:03 PM In reply to

    Re: Have problems sending data from one repeating table to another.

    If a repeating table within the form can be used as a data source then it would be correct.  If I am understanding correctly now, the Me.DataSources("PartsListUpdate") actually refers to an external Data Connection that has the same name.  If this is the case, I can create an external data connection named("PartsListUpdate") but it will not have data in it.

  • 05-28-2013 12:05 PM In reply to

    Re: Have problems sending data from one repeating table to another.

    Hilary, you are right with the last response. The repeating table is in located in the Main Fields.

  • 05-28-2013 12:06 PM In reply to

    Re: Have problems sending data from one repeating table to another.

     Okay - so you need to change your code so you aren't trying to get something not in the main data source. Try my suggestion above.

    Hilary Stoupa

  • 05-28-2013 12:08 PM In reply to

    Re: Have problems sending data from one repeating table to another.

    Much closer now:

    System.NullReferenceException
    Object reference not set to an instance of an object.
       at Bridge_22Apr13.FormCode.CTRL1334_9_Clicked(Object sender, ClickedEventArgs e)
       at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
       at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

  • 05-28-2013 12:16 PM In reply to

    Re: Have problems sending data from one repeating table to another.

    Can you run your code in debug to see where the null ref is occurring? Sorry - I know I've asked repeatedly in this thread if you know how to run in debug, but I don't recall seeing an answer yet.

    Hilary Stoupa

Page 2 of 3 (43 items) < Previous 1 2 3 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.