Deleting rows from repeating table - InfoPath Dev
in

InfoPath Dev

Deleting rows from repeating table

Last post 11-09-2010 02:19 PM by Jose9Reyes. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 11-09-2010 12:53 PM

    Deleting rows from repeating table

    Hey guys Im back again as Im stuck in a bit of a mess and really confused. I have a form which has a repeating table. I have a text field which takes a input from the user and then inserts the required amount of rows into the repeating table using the changed Attribue Changed method. Now on another form I have the same thing and it works perfectly.

     I have used the same coding and changed the variables accordingly to the form but get the following error everytime I change the number, for example if 5 is inputted and 5 rows are created. However if I then change that 5 to anything less (apart from 4 as if i choose the number below it works :/) I get the following error:

    System.Runtime.InteropServices.COMException was unhandled by user code
      ErrorCode=-2147207413
      Message="The specified bstrAction value for the View.ExecuteAction call is not applicable for the current selection."

     Now from what I have been thinking I believe it maybe trying to delete a row which has already been deleted?

     Below is the code:

    Dim numberOfSafes As XPathNavigator = _

    Me.MainDataSource.CreateNavigator().SelectSingleNode( _

    "/dfs:myFields/dfs:dataFields/d:tblSite/d:tblAlarm/@FreeStandingCashSafeTotal", NamespaceManager)

    Dim root As XPathNavigator = Me.CreateNavigator()

    Dim nodes As XPathNodeIterator = _

    root.Select("/dfs:myFields/dfs:dataFields/d:tblSite/d:tblAlarm/d:tblFreeStandingCashSafe/@SafeBoltMonitoring", NamespaceManager)

    '/@SafeBoltMonitoring

    Dim counter As Integer = 0

    Dim amountSafes As Integer = 0

    'Check if numberOfSafes is empty or 0

    If (numberOfSafes.ToString = "") Or (numberOfSafes.ToString = "0") Then

    numberOfSafes.SetValue(1)

    End If

    'If numberOfSafes are less then nodes in table

    If numberOfSafes.ValueAsInt > nodes.Count Then

    amountSafes = numberOfSafes.ValueAsInt - nodes.Count

    Do While counter < amountSafes

    CurrentView.ExecuteAction(ActionType.XCollectionInsert, "tblFreeStandingCashSafe_1543")

    counter = counter + 1

    Loop

    End If

    'If numberOfSafes is less then nodes in table

    If numberOfSafes.ValueAsInt < nodes.Count Then

    amountSafes = nodes.Count - numberOfSafes.ValueAsInt

    Do While counter < amountSafes

    If CurrentView.ToString IsNot Nothing Then

    CurrentView.ExecuteAction(ActionType.XCollectionRemove, "tblFreeStandingCashSafe_1543")

    counter = counter + 1

    End If

    Loop

    End If

    The next post is on the other form and actually works how it is required to.

  • 11-09-2010 12:57 PM In reply to

    Re: Deleting rows from repeating table

    Dim numberOfDVRs As XPathNavigator = _

    Me.MainDataSource.CreateNavigator().SelectSingleNode( _

    "/dfs:myFields/dfs:dataFields/d:tblSite/d:tblCctv/@NumberOfDVRs", NamespaceManager)

    Dim root As XPathNavigator = Me.CreateNavigator()

    Dim nodes As XPathNodeIterator = _

    root.Select("/dfs:myFields/dfs:dataFields/d:tblSite/d:tblCctv/d:tblDVR/@DVRType", NamespaceManager)

    Dim counter As Integer = 0

    Dim amountDVR As Integer = 0

    Dim nodeCount As Integer = 0

    'Check if numberOfDVRs is either empty or 0

    If (numberOfDVRs.ToString = "") Or (numberOfDVRs.ToString = "0") Then

    numberOfDVRs.SetValue(1)

    End If

    'If numberOfDVRs isnt empty

    If numberOfDVRs.ToString > nodes.Count Then

    amountDVR = numberOfDVRs.ValueAsInt - nodes.Count

    Do While counter < amountDVR

    CurrentView.ExecuteAction(ActionType.XCollectionInsert, "tblDVR_867")

    counter = counter + 1

    Loop

    End If

    If numberOfDVRs.ToString < nodes.Count Then

    amountDVR = nodes.Count - numberOfDVRs.ValueAsInt

    Do While counter < amountDVR

    If CurrentView.ToString IsNot Nothing Then

    CurrentView.ExecuteAction(ActionType.XCollectionRemove, "tblDVR_867")

    counter = counter + 1

    End If

    Loop

    End If

     This code works but I cannot seem to phathom why one works and the other doesnt. Would highly appreciate some help here guys.

  • 11-09-2010 02:19 PM In reply to

    Re: Deleting rows from repeating table

    Ok, I have just realised that if I change the below field on the form from a Checkbox to a Text field it works:

     

    Dim nodes As XPathNodeIterator = _

    root.Select("/dfs:myFields/dfs:dataFields/d:tblSite/d:tblAlarm/d:tblFreeStandingCashSafe/@SafeBoltMonitoring", NamespaceManager)

     

    Any reason why the type of field will stop it from working?

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.