When creating a sales order (with SOLines subform), if the user doesn't know the ItemNum, I want him to exit the ItemNum field blank, which then triggers the following programming: - go find all Pricing records for (only) this clientID - make a popup list of those pricing records (list consisting of ItemDesc + clientID) - choose one of the line items - the ItemNum value is extracted from the popup choice and plugged into ItemNum field - regular ItemNum OnElementChange programming is then triggered.
For the first SOLines record added, the programming works flawlessly, creating a popup list of only that client's Pricing records. If I save that SOLines record with Sesame Save command, and then use the Sesame > button to add a second record, then the programming works flawlessly. But if I save that first SOLines record with a command button that I built (which ends with the following code) and attempt to repeat the procedure for a 2nd line item, the popup list then shows ALL of the Pricing records in the Pricing database. What am I missing in my code?
"Save this record and create a new record" command button ending code: XResultSetClose(vRS5) }
vTemp = @CreateNewRecord() ThrowFocus(ItemNum) } ****************************
The programming for the XResultSet and the PopupChoiceList ......
#Include "sbasic_include.sbas"
var vRS as Int var vCount as Int var vLoop as Int var vLine as String var vList as String var vChoice as String var vFound as Int var vClientID as string var vStartswith as string
// vStartswith = ".." + ThisElement + ".."
// vClientID = ClientID vRS = 0
If @Mode() = 0 and @IsBlank(ItemNum) { vList = "" vClientID = ClientID vRS = @XResultSetSearch(@FN, "Pricing", SEARCH_MODE_OR, SEARCH_SYNTAX_QA, "ClientID=" + vClientID) XResultSetSort(vRS, "ItemDesc") If vRS > -1 { vCount = @XResultSetTotal(vRS) If vCount = 0 { @MsgBox("No matching records.", "Click on ItemNum field and build a new Inventory record", "The programming will instruct you") } Else If vCount = 1 { // Fill in the values haven't done this part yet } Else { vList = "" For vLoop = 1 To vCount XResultSetCurrentPosition(vRS, vLoop) vLine = @XResultSetValue(vRS, "ItemDesc") + " ~ " + @XResultSetValue(vRS, "ItemNum") vList = vList + vLine + ";" Next vList = @ReplLas(vList, ";", "") PopupSelectPosition(4, @Xpos(ItemNum)+10, @Ypos(ItemNum)+10) vChoice = @PopupChoiceList(vList, "SELECT A RECORD") If vChoice <> "" { vChoice = @Mid(vChoice, @Instr(vChoice, "~") + 1, 500) ItemNum = vChoice ThrowFocus(ItemNum) } } } XResultSetClose(vRS) }
|