Normal Topic PopupChoiceList with XResultSetSearch (Read 594 times)
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
PopupChoiceList with XResultSetSearch
Apr 9th, 2009 at 7:57pm
Print Post Print Post  
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)
   }
  

Larry
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: PopupChoiceList with XResultSetSearch
Reply #1 - Apr 10th, 2009 at 11:44am
Print Post Print Post  
You'll pull all the records from the Pricing database if ClientID is empty, of course. So, does ClientID have a value by the time @XResultSetSearch executes.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: PopupChoiceList with XResultSetSearch
Reply #2 - Apr 10th, 2009 at 12:48pm
Print Post Print Post  
Carl,

I owe you a big piece of chocolate cake and a glass of milk.  You were right - ClientID wasn't getting filled first.  

Thanks so much!

« Last Edit: Apr 10th, 2009 at 2:29pm by lksseven »  

Larry
Back to top
IP Logged