if (Subform1.FileName.rawValue == null || Subform1.FileName.rawValue == ""){
var nMaxID =0;
//Reset DB to first record
var oDB = xfa.sourceSet.DataConnection1;
try{
oDB.first();
}
catch(e){
oDB.open();
oDB.first();
}
//walk thru all records to find latest file ID
while(!oDB.isEOF()){
if(xfa.record.DataConnection1.FileName.value > nMaxID)
var vValue = xfa.record.DataConnection1.FileName.value;
nMaxID = Number(vValue);
oDB.next();
}
oDB.addNew();
Subform1.FileName.rawValue = (nMaxID + 1);
Hide1.FileName1.rawValue = Subform1.FileName.rawValue;
oDB.update();
Hide1.EmployeeNo.rawValue = Subform1.EmployeeNo.formattedValue;
Hide1.Originator.rawValue = Subform1.Originator.rawValue;
Subform11.FileName.rawValue = Subform1.FileName.formattedValue;
this.resolveNode("OrderDate").rawValue = util.printd("yyyy-mm-dd", new Date());
Hide1.DateTimeExitedEmpNumber.rawValue = Subform4.DateTimeExitedEmpNumber.rawValue;
oDB.update();
oDB.close();
}
else{
//HEADER SECTION
//Reset DB to first Record
var oDB = xfa.sourceSet.DataConnection1;
oDB.open();
try{
oDB.first();
}catch(e){
oDB.open();
oDB.first();
}
//Walk thru all records until test value is matched
var oFile = Subform1.FileName.formattedValue;
var bFound = false;
while(!oDB.isEOF()){
if(xfa.record.DataConnection1.FileName.value == oFile){
bFound = true;
break;
}
oDB.next();
}
if(bFound){
}
Hide1.EmployeeNo.rawValue = Subform1.EmployeeNo.formattedValue;
Hide1.Originator.rawValue = Subform1.Originator.rawValue;
Subform1.FileName.rawValue = Subform1.FileName.rawValue;
oDB.update();
oDB.close();
}