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.