Chad, You can do this whit one SELECT (I think)
m.ldBeginDate = thisform.ldbdate
m.ldEndDate = thisform.ldedate
SELECT (field list here w/o LastCdate), NVL(Table3.InvDte, MAX(NVL(Table4.InvDte,{})) AS LastCdate;
FROM Table1 ;
LEFT JOIN Table3 ON Table1.Customer + Table1.Ecustomer == Table3.Customer + Table3.Ecustomer;
LEFT JOIN Table4 ON Table1.Customer + Table1.Ecustomer == Table4.Customer + Table4.Ecustomer;
WHERE Table1.salesrep = thisform.lcsalesrep AND ;
BETWEEN(Table1.quotedate, m.ldBeginDate, m.ldEndDate) AND ;
EMPTY(current) AND EMPTY(status) ;
ORDER BY customer, ecustomer ;
GROUP BY (full field list here w/o LastCDate) ;
INTO CURSOR a_tmpf READWRITE
(not tested I only think that this should work)
About your problem, You SKIP Table 1 twice first in SCAN ENDSCAN loop and second in DO WHILE loop, maybe you want to DO WHILE in Table4 to get the latest date, but current area is Tabel1 thats why you DO WHILing in it and mey in REPLACE you at the EOF() state of table and can't perform the replace.
>Hello all,
>
>I am having a problem at runtime. The following code works well from a development environment. But, when I put the application into the runtime menu, the cursor becomes read only.
>
>SELECT * from Table1 ;
> WHERE Table1.salesrep = thisform.lcsalesrep AND ;
> BETWEEN(Table1.quotedate, thisform.ldbdate, thisform.ldedate) AND ;
> EMPTY(current) AND EMPTY(status) ;
> ORDER BY customer, ecustomer ;
> INTO CURSOR a_tmpf readwrite
>
>
>I then need to scan through the cursor. I do so with the following code:
>
>*-- Establish relation between tmpf cursor and Table2 for reporting
>SELECT a_tmpf
>SET RELATION TO ecustomer INTO Table2
>
>
>*-- Locate last rebate
>GOTO top
>SCAN
> IF SEEK(customer + ecustomer, "Table3","invno2")
> replace a_tmpf.lastcdate WITH Table3.invdte
> ENDIF
> IF EMPTY(a_tmpf.lastcdate)
> *-- set date insertion variable
> ldmaxdate = {}
> IF SEEK(customer+ecustomer, "Table4","invno2")
> DO WHILE a_tmpf.customer + a_tmpf.ecustomer = ;
> Table4.customer + Table4.ecustomer And !EOF()
> ldmaxdate = Table4.invdte
> SKIP
> ENDDO
> ENDIF
> replace a_tmpf.lastcdate WITH ldmaxdate
> ENDIF
>ENDSCAN
>
>
>The problem is when the Scan begins. The cursor "a_tmpf" is read only and not updatable.
>
>What am I doing wrong? Any ideas?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.