Solved

Infopath Custom Code Issue

Posted on 2013-10-29
7
357 Views
Last Modified: 2013-11-04
I am using a loop to iterate through my Main Nodes in a repeating table in Infopath 2010.
When I get to the field that I am using a calculated value as the default I am getting an error, "Object reference not set to an object",

Here is my code:

 'Count the amount of Field nodes
            Dim iter As XPathNodeIterator = root.Select("/my:myFields/my:ImportFields/my:Fields", NamespaceManager)
            Dim FieldsCount As Integer = iter.Count
            Dim sb As New System.Text.StringBuilder()

            If FieldsCount > 0 Then
                'Check mappings.
                While iter.MoveNext
                    If iter.Current.SelectSingleNode("my:FieldName", NamespaceManager).Value = "" Or iter.Current.SelectSingleNode("my:MappedField", NamespaceManager).Value = "None" Then
                        sb.Append("Row " & iter.Current.SelectSingleNode("my:RowNo", NamespaceManager).Value & " is not mapped." & System.Environment.NewLine)
                    End If
                End While

Open in new window

0
Comment
Question by:redeux-tech
  • 5
  • 2
7 Comments
 
LVL 28

Expert Comment

by:clayfox
ID: 39609404
You may have the recalculate check box on the default value. It may be looping trying to recalculate when you move through the field.
0
 
LVL 1

Author Comment

by:redeux-tech
ID: 39609569
I already tried removing the check box and it is still not working.
0
 
LVL 28

Expert Comment

by:clayfox
ID: 39609577
Maybe try removing the default value and just use a rule or code at load that sets the value.

Might allow you to get around the issue.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:redeux-tech
ID: 39609582
This what the error looks like in progress....
0
 
LVL 1

Author Comment

by:redeux-tech
ID: 39609686
I have the datasource for this field set to position().  Is that what is causing this to not return a value?
0
 
LVL 1

Accepted Solution

by:
redeux-tech earned 0 total points
ID: 39612074
Ok, I figured out my own problem here.  

1 -  I had to fix the field so that it's datasource was no longer position()

2-  I had to map the calculated value field so that it was mapped to the field on the Main datasource so that the value was saved.

3 -  I set the field's default value to count(preceding-sibling::*/RowNo) + 1 and it doesn't matter that refresh value when formula is calculated is checked.

4 - I had to make sure that my code that inserted new rows into the repeating table (XMLWriter) was inserting the nodes in the correct order as they appeared in the Main datasource.
0
 
LVL 1

Author Closing Comment

by:redeux-tech
ID: 39621080
I solved my own issue and I outlined the solution in this comment.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB6 Compile Compatibility Issue 4 87
Access query that references subform 5 43
Hide vba in gp 7 79
XSL FO - text wrapping and empty spaces 1 25
Before you can digitally sign infopath forms, you must have a digital certificate. Microsoft Certificate Services will need to be enabled on a Windows Server 2008 to facilitate the creation and verification of the digital certifciates on the web ser…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now