>>Without seek before select SUM I got the following results
>>Found a mismatch on I801972COL cRate = 0 laArr[1]= 0.100000000
>>Found a mismatch on I518767COL cRate = 0 laArr[1]= 0.100000000
>>
>>The first invoice has a different person as a salesman, and the second doesn't exist in Comision at all (I just tried in Command window to search for these invoices).
>
>The two commands may well leave the record pointer in different places.
>
>Tamar
That's true, but here is the exact code
SELECT Comision
lnRecno = RECNO()
SET ORDER TO com_inv IN comision
SELECT SUM(rate*SHARE/10000) AS crate WHERE inv_no+salesman = m.ccinv + m.Slsman ;
FROM comision INTO ARRAY laArr
lcRate = EVL(laArr[1],0)
IF SEEK(m.ccinv + m.Slsman)
SUM (rate*SHARE/10000) TO cRate WHILE inv_no+salesman = m.ccinv + m.Slsman
ELSE
cRate = 0
endif
IF NOT m.cRate == m.lcRate
=MESSAGEBOX("Found a mismatch on " + m.ccinv + m.Slsman)
_cliptext = _cliptext + "Found a mismatch on " + m.ccinv + m.Slsman + " cRate = " + ;
TRANSFORM(m.cRate) + " laArr[1]= " + TRANSFORM(m.lcRate)
ENDIF
The two reported mismtach cases are wrong, since in first case the invoice is for different person and in second it doesn't exist. I just re-indexed the table on inv_no + salesman and the problem persists.
Do you know, what I'm doing wrong?
Thanks again.
If it's not broken, fix it until it is.
My Blog