Programmatically Adding Data to Table Rows - InfoPath Dev
in

InfoPath Dev

Programmatically Adding Data to Table Rows

Last post 04-25-2006 01:50 PM by Doug Myers. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 04-24-2006 10:57 AM

    Programmatically Adding Data to Table Rows

    The following VBScript produces new table rows but unfortunately the data is simply re-written over the first row (node). I am sure there is something obvious that I am missing, but I could use some help identifying the problem. Here's a slice of the code:

    (Note: rsObj is a recordset from SQL)

    insideLoop = False
    i=0

    Do Until rsObj.EOF
    If insideLoop then
    XDocument.View.ExecuteAction "xCollection::insert", "group2_201"
    End if

    set nodesDetail = XDocument.DOM.selectNodes("/my:myFields//my:group2")

    set row = nodesDetail.item(i)

    row.selectSingleNode("/my:myFields//my:field1").text = Flds(1).Value

    insideLoop = True
    i = i + 1
    rsObj.MoveNext
    Loop

    The data is successfully obtained from an SQL database and is in the array "Flds." My test case produced 5 rows (to match the 5 Flds values) but only the first row contained the last result.
  • 04-25-2006 01:46 PM In reply to

    Re: Programmatically Adding Data to Table Rows

    Your row.selectSingleNode() XPath is the problem. You are giving it an absolute XPath from the top of your schema instead of a relative XPath staring from the node itself.

    It should probably be something like row.selectSingleNode("my:field1").text = ...
  • 04-25-2006 01:50 PM In reply to

    Re: Programmatically Adding Data to Table Rows

    Thanks, Greg. It's sometimes tough to see the forest for the trees.
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.