B
Bromley
I get a message saying "Object Required line 42" when I run the function
below... line 42 is the beginning of the if statement...
I am admittedly not familiar with the Infopath object model...
This code was taken from this discussion group, and I have tried to adapt it
to connect to my database and secondary table... FYI... the Implementations
tabel and the Tasks table are part of my main database connection and are in
access... Task master is a secondary connection to the same database.
function CTRL83_7::OnClick(eventObj)
{
//Get a reference to the Table1 data connection
var objTable1DOM = XDocument.GetDOM("TaskMaster");
//Set the SelectionNamespaces property of the Table1 data connection to
walk the DOM
objTable1DOM.setProperty("SelectionNamespaces",
'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
' +
'xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"');
//Get the selected items
var objSelectedItems =
objTable1DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:TaskMaster[@Selected= 'True']");
//Loop through the selected items
for(i=0;i<=objSelectedItems.length -1;i++)
{
//See if the first record in the destination Repeating Table is blan
if(XDocument.DOM.selectSingleNode("//my:Implementations/my:Tasks/my:Item").text == "")
XDocument.DOM.selectSingleNode("//my:Implementations/my:Tasks/my:Item").text = objSelectedItems(i).attributes(1).text;
}
else
{
//Add a new row
XDocument.View.ExecuteAction("xCollection::insert", "Tasks_23");
//Get a reference to that new row
var objNewItem =
XDocument.DOM.selectSingleNode("//my:Implementations/my:Tasks[last()]/my:Item");
//Set the text of the field
objNewItem.text = objSelectedItems(i).attributes(1).text;
}
}
}
below... line 42 is the beginning of the if statement...
I am admittedly not familiar with the Infopath object model...
This code was taken from this discussion group, and I have tried to adapt it
to connect to my database and secondary table... FYI... the Implementations
tabel and the Tasks table are part of my main database connection and are in
access... Task master is a secondary connection to the same database.
function CTRL83_7::OnClick(eventObj)
{
//Get a reference to the Table1 data connection
var objTable1DOM = XDocument.GetDOM("TaskMaster");
//Set the SelectionNamespaces property of the Table1 data connection to
walk the DOM
objTable1DOM.setProperty("SelectionNamespaces",
'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
' +
'xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"');
//Get the selected items
var objSelectedItems =
objTable1DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:TaskMaster[@Selected= 'True']");
//Loop through the selected items
for(i=0;i<=objSelectedItems.length -1;i++)
{
//See if the first record in the destination Repeating Table is blan
if(XDocument.DOM.selectSingleNode("//my:Implementations/my:Tasks/my:Item").text == "")
XDocument.DOM.selectSingleNode("//my:Implementations/my:Tasks/my:Item").text = objSelectedItems(i).attributes(1).text;
}
else
{
//Add a new row
XDocument.View.ExecuteAction("xCollection::insert", "Tasks_23");
//Get a reference to that new row
var objNewItem =
XDocument.DOM.selectSingleNode("//my:Implementations/my:Tasks[last()]/my:Item");
//Set the text of the field
objNewItem.text = objSelectedItems(i).attributes(1).text;
}
}
}