I'm stumped. Upon saving parent Orders, trying to loop through subform SOLines, FormDeleteRecord if the subform record is "spacer", then @FormNewRecord and populate the new "spacer" record with data, then save. Code will delete correctly, but when it gets to FormNewRecord, it doesn't create a new record, it steps on the last good record. For example, I pull up a sales order with 3 subrecords, one of which is a 'spacer' record and the code will delete, then add a new 'spacer' record. So the writeln's should be vStot = 3 (three original records) vStot = 2 (the total after deleting the spacer record) vNSOR = 3 (the total after @FormNewRecord) vStot = 3. (the total after the code is finished populating the 'new' record).
But what I get is:
vStot = 3 (three original records) vStot = 2 (the total after deleting the spacer record) vNSOR = 3 (the total after @FormNewRecord) vStot = 2 (problem: this should be "3", but the @FormNewRecord didn't "take", and so the programming pulls up the last exiting good subform record (record #2) and steps on it.)
What am I doing wrong?
If (vClientMailToDifferent <> "") and (vInvoiceEmailAddress <> "") // and (vSpace <> "Y") // variables obtained from RSdni XResultSetSearch above {
FormCommit("SOLines") FormCommit("")
vStot = @FormResultSetTotal("SOLines")
writeln("vStot = " + vStot)
vLoopS = 1 For vLoopS = 1 to vStot vIS = 0 vIS = @FormFieldValue("SOLines", "ItemNum", vLoopS) If vIS = "SPACER" { WarningLevel(0) FormDeleteRecord("SOLines", vLoopS) WarningLevel(1) vStot = vStot - 1 } vLoopS = vLoopS + 1 Next
FormCommit("SOLines") FormCommit("")
FormNotifyForm("SOLines", -7) vStot = @FormResultSetTotal("SOLines")
writeln("vStot = " + vStot)
vNSOR = @FormNewRecord("SOLines")
writeln("vNSOR = " + vNSOR)
FormCommit("SOLines") FormCommit("") vStot = @FormResultSetTotal("SOLines")
writeln("vStot = " + vStot) FormFieldValue("SOLines", "ItemNum", vStot, "SPACER") FormFieldValue("SOLines", "ItemCat", vStot, "DESC")
FormFieldValue("SOLines", "SONum", vStot, "vSONum") FormFieldValue("SOLines", "PorM", vStot, "M") FormFieldValue("SOLines", "Posted", vStot, "P") FormCommit("SOLines") FormCommit("")
}
// ////////////// end of the Spacer SOLines section
|