Normal Topic @XResultSetSearch (Read 477 times)
Stew Bell
Member
*
Offline



Posts: 21
Joined: Dec 17th, 2011
@XResultSetSearch
Jan 1st, 2014 at 10:52pm
Print Post Print Post  
I am attempting to use the @XResultSetSearch.
Seems so powerful compared to XLookup.
If I understand it, you can choose a set of records which match a variety of search criterion.  Then you can extract info from the various fields within the Result Set.

I have an application called ATM Triangle HST IFTA
in this app I have databases HST   IFTA    ATM
ATM Month Totals    and    2nd US and Tri Bank Accts.

There is one form for each db.

I am trying to retrieve a set of records from the "Bank Accts" form in 2nd US and Tri Bank Accts db  based on date and account search criteria; then extract the total from all of the deposit fields entries in the retrieved ResultSet and put it in the ATM Month Totals form.

In the ATM form it is two digits for the month and four digits for the year.  So I combined them into ] + Year + "/" + month +"/??"  in another element and use that to match the date. (Any day of that month, in that year)

All I can get is $0.00

This is the code that I copied and altered.

var vRSHandle as int
var vNoOfRecords as int
var vLoop as int
var vdeposit as double
     

     vRSHandle = @XResultSetSearch("@FN", " 2nd US and Tri Bank Accts ", 0, 2, "!Accounts=Tr..", "!D_ate=code")
     if(vRSHandle > -1)
     {
           vNoOfRecords = @XResultSetTotal(vRSHandle)
           for vLoop = 1 to vNoOfRecords
                 XResultSetCurrentPosition(vRSHandle, vLoop)
                 vdeposit = @XResultSetValue(vRSHandle, "deposit")
                 
                 
           next
           XResultSetClose(vRSHandle)
     }

     Triangle Deposits for Month = @sum(vdeposit)
                 WriteLn(vdeposit)

  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @XResultSetSearch
Reply #1 - Jan 2nd, 2014 at 2:05pm
Print Post Print Post  
Without knowing precisely what variable and elements you have available, I have guessed that you might want to try something closer to this:

Code
Select All
var vRSHandle as int
var vNoOfRecords as int
var vLoop as int
var vdeposit as money
    
     vdeposit = 0
     vRSHandle = @XResultSetSearch(@FN, " 2nd US and Tri Bank Accts ", 0, 2, "!Accounts=Tr..", "!D_ate=" + code)
     if(vRSHandle > -1)
     {
           vNoOfRecords = @XResultSetTotal(vRSHandle)
           for vLoop = 1 to vNoOfRecords
                 XResultSetCurrentPosition(vRSHandle, vLoop)
                 vdeposit = vdeposit + @ToMoney(@XResultSetValue(vRSHandle, "deposit")) 
           next
           XResultSetClose(vRSHandle)
     }
     Triangle Deposits for Month = vdeposit
     WriteLn(vdeposit)
 



You may need to adjust for your actual case.  The main changes are the placement and removal of double quotes. Double quotes are only used when you want a literal value. If you are trying to use a variable, element name, function, or subroutine, it shouldn't be in double quotes.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged