Chris,
I saw your request after my last posting, so here is the full script from the Initialize event of the Select ID drop down field:
var sDataConnectionName = "DataConnection2";
var sCol1 = "ID";
var sCol2 = "PART_NO";
var sCol3 = "DESCRIPTION";
var sCol4 = "UNITPRICE";
//Search for sourceSet node which matches the DataConnection name
var nIndex = 0;
while(xfa.sourceSet.nodes.item(nIndex).name != sDataConnectionName)
{
nIndex++;
}
var oDB = xfa.sourceSet.nodes.item(nIndex);
oDB.open();
oDB.first();
//Search node with the class name "command"
var nDBIndex = 0;
while(oDB.nodes.item(nDBIndex).className != "command")
{
nIndex++;
}
// Backup the original settings before assigning BOF and EOF to stay
var sBOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("bofAction");
var sEOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("eofAction");
// Need to set BOF and EOF to stay
oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayBOF","bofAction");
oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayEOF","eofAction");
//Clear the list
this.clearItems();
//Search for the record node with the matching Data Connection name
nIndex = 0;
while(xfa.record.nodes.item.(nIndex).name != sDataConnectionName)
{
nIndex++;
}
var oRecord = xfa.record.nodes.item(nIndex);
// Find the values of the record
// Find the value node
var oValueCol1 = null;
var oValueCol2 = null;
var oValueCol3 = null;
var oValueCol4 = null;
for(var nColIndex = 0; nColIndex < oRecord.nodes.length; nColIndex++)
{
if(oRecord.nodes.item(nColIndex).name == sCol1)
{
oValueCol1 = oRecord.nodes.item(nColIndex);
}
else if(oRecord.nodes.item(nColIndex).name == sCol2)
{
oValueCol2 = oRecord.nodes.item(nColIndex).value;
}
else if(oRecord.nodes.item(nColIndex).name == sCol3)
{
oValueCol3 = oRecord.nodes.item(nColIndex).value;
}
else if(oRecord.nodes.item(nColIndex).name == sCol4)
{
oValueCol4 = oRecord.nodes.item(nColIndex).value;
}
}
while(!oDB.isEOF())
{
this.addItem(oValueCol1.value, oValueCol2.value, oValueCol3.value, oValueCol4.value);
oDB.next();
}
// Resotre the original settings
oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sBOFBackup, "bofAction");
oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sEOFBackup, "eofAction");
// Close connection
oDB.close();