FWIW, 'most' of the random crashes occur when this command button is executed in the making of a sales order (it checks on various things in the Sales Order header, conditionally adds a map image, and then throws focus to the SOLines subform (LEO) to add line items).
var vSONum as int var vNextSONum as int var vClientID as string var vRSc as int var vMaplink as string var vCount as int var vShipToID as string var vClientPO as string var vClientPORequired as string var vOrderer as string var vPass as int var vErrorList as string //var vAltP as string //var vCheck as string
var vSOTot as int var vItemNum as string var vItemDesc as string var vItemQty as string var vItemUoM as string var vItemPrice as double var vExtendedPrice as double var vLoop1 as int var vLine as string var vItemNum2 as string var vPrint as int
If @Group <> "clients" {//a
If @Mode() = 1 {
If @SubformVisibility("LE0") = 0 { Visibility(SummaryView, 0) SubformVisibility("LE0", 1) FormAttribute("SOLines", "CreateNewItem", ATTR_ID_READ_ONLY, "0") vItemNum2 = "" vItemNum2 = @FormAttribute("SOLines", "ItemNum", 0) If vItemNum2 <> "" { FormAttribute("SOLines", "ItemNum", ATTR_ID_READ_ONLY, "1") } FormThrowFocus("SOLines", "LaunchPad") }
else If @SubformVisibility("LE0") = 1 {
vSOTot = @FormResultSetTotal("Orders!SOLines") vLoop1 = 1 While vLoop1 <= vSOTot
{ vItemNum = @FormFieldValue("SOLines", "ItemNum", vLoop1) vItemDesc = @FormFieldValue("SOLines", "ItemDesc", vLoop1) vItemQty = @FormFieldValue("SOLines", "ItemQty", vLoop1) vItemUoM = @FormFieldValue("SOLines", "ItemUoM", vLoop1) vItemPrice = @FormFieldValue("SOLines", "ItemPrice", vLoop1) vExtendedPrice = @FormFieldValue("SOLines", "LineItemTotal", vLoop1) vLine = vLine + vItemNum + " ** " + vItemDesc + " ** " + vItemUoM + " ** " + vItemQty + " ** $" + vItemPrice + " ** $" + vExtendedPrice + @NewLine() + "===============" + @NewLine()
vLoop1 += 1 } SubformVisibility("LE0", 0) Visibility(SummaryView, 1) SummaryView = "" SummaryView = vLine ForceRedraw() } // end LE0 = 1
}
If @Mode() = 0 {//b vPass = 1
If @IsBlank(SONum) { //SubformVisibility(LE0, 0) ThrowFocus(SONum) } else If (@IsBlank(SONum) = 0) {//be //SubformVisibility(LE0, 1) //NotifyForm(6)
vShipToID = ShipToID vClientPO = ClientPO vOrderer = Orderer vClientID = ClientID vMaplink = "" //vAltP = AltP //vCheck = @ContainsStringArray(vClientPO, "card", 0)
vRSc = @XResultSetSearch(@FN, "Client", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!ClientID=" + vClientID) If vRSc > -1 {
vCount = @XResultSetTotal(vRSc) If vCount = 1 { vClientPORequired = @XResultSetValue(vRSc, "ClientPORequired") vMaplink = @XResultSetValue(vRSc, "MapLink") If @IsBlank(Orderer) { vErrorList = vErrorList + @NewLine() + " [X] Orderer field must contain the name of the customer who placed this order" + @NewLine() vPass = 0 }
If (vClientPORequired <> "") and @IsBlank(ClientPO) { vErrorList = vErrorList + @NewLine() + " [X] a PO# is required for this customer" + @NewLine() vPass = 0 }
/* If (vAltP = "") and (@Left(vClientID,4) = "1007") and (vCheck <> "") { vErrorList = vErrorList + @NewLine() + " [X] If client is TU and PO is Pcard and item is copy paper, be sure to enter a 'P' in AltP field" + @NewLine() vPass = 0 } */
If vPass = 0 { Writeln(vErrorList) Writeln(@NewLine() + @NewLine() + " The above must be corrected before you can proceed with this order") } else If vPass = 1 { //begin vPass = 1
//FormCommit("") If (vShipToID = "") { If vMapLink <> "" { Map1 = vMaplink } }
If @SubformVisibility("LE0") = 0 { Visibility(SummaryView, 0) SubformVisibility("LE0", 1) FormAttribute("SOLines", "CreateNewItem", ATTR_ID_READ_ONLY, "0") vItemNum2 = "" vItemNum2 = @FormFieldValue("SOLines", "ItemNum", 0) //vItemNum2 = @FormAttribute("SOLines", "ItemNum", 0) If vItemNum2 <> "" { FormAttribute("SOLines", "ItemNum", ATTR_ID_READ_ONLY, "1") } FormNotifyForm("SOLines", 6) FormThrowFocus("SOLines", "LaunchPad") }
else If @SubformVisibility("LE0") = 1 { FormCommit("") vSOTot = @FormResultSetTotal("Orders!SOLines") vLoop1 = 1 While vLoop1 <= vSOTot
{ vItemNum = @FormFieldValue("SOLines", "ItemNum", vLoop1) vItemDesc = @FormFieldValue("SOLines", "ItemDesc", vLoop1) vItemQty = @FormFieldValue("SOLines", "ItemQty", vLoop1) vItemUoM = @FormFieldValue("SOLines", "ItemUoM", vLoop1) vItemPrice = @FormFieldValue("SOLines", "ItemPrice", vLoop1) vExtendedPrice = @FormFieldValue("SOLines", "LineItemTotal", vLoop1) vLine = vLine + vItemNum + " ** " + vItemDesc + " ** " + vItemUoM + " ** " + vItemQty + " ** $" + vItemPrice + " ** $" + vExtendedPrice + @NewLine() + "===============" + @NewLine()
vLoop1 += 1 } SubformVisibility("LE0", 0) Visibility(SummaryView, 1) SummaryView = "" SummaryView = vLine ForceRedraw() } // end LE0 = 1
} // end vPass = 1
} // end vCount = 1
} // end vRSC > -1
//NotifyForm(-6) XResultSetClose(vRSc)
}//end of be
} // end of b
} // end of a
|