Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with this code 1

Status
Not open for further replies.

EKC

Technical User
Jan 13, 2001
43
CA
Hi everyone,

I have Select statement

Select cust,orderID,partID,date,Qty from Table1 order by cust into cursor c_report
I need to go through each record in this c_report and make date field to closest Friday(ship date).I tried something like this
Select c_report
Scan
do While Dow(back_report.ordate )<>6
back_report.ordate=back_report + 1
EndDo
EndScan



but I have message &quot;Object c-report not found&quot;
Beeing new to VFP ,I'm not sure how to get around this problem.

Thanks for any help,
Lyn
 
Replace 'cursor' with 'DBF' .. so the SQL will run ....

Select cust,orderID,partID,date,Qty from Table1 order by
cust into DBF c_report

By this the c_report will be made available.
(Note.. you cannot assume anything woth cursor wether it realy exists as database file in your harddisk/storage... to make it available, you shall use DBF and this DBF will be made available in harddisk. To remove this.. delete the DBF c_report. In single user software this is not important, since c_report will be overwritten again and again. However in multiuser status, the same report name will be used simulataneouly by others. So you can use a SYS(3)to a variable and use that variable in the place of the c_report. Hope I have explained more than required. If needed you can ask more specificaly.) :)
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
Think of constructing ... which could end up in creating cursor and manipulation in one stroke.... like this

Select cust, orderID, partID, ordate, ;
IIF(DOW(ordate)<=6,ordate+6-DOW(ordate),ordate+13-DOW(ordate)) AS date, Qty ;
from Table1 order by cust into cursor c_report
:) ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
Two tips !!! 1. Remain on the same SQL stament but send the data to a array and handle it from the there and the second try to use multiple SQL statement with your conditions. Have fun .
 
If your code is as follows:
Select cust,orderID,partID,date,Qty from Table1 order by cust into cursor c_report
Select c_report


and your error message is:
&quot;Object c-report not found&quot;

Then, somewhere in your code/report you are referencing the cursor alias with a hyphen instead of an underscore.

To determine the next Friday, you can use:

SELECT *,mydate+(7-dow(mydate,7)) As NextFriday FROM Table1 INTO CURSOR c_report Jon Hawkins

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Just my little thought:
Code:
SELECT .... INTO CURSOR c_report
*!* note that the cursor is 'selected' now
IF _TALLY > 0
   *!* cursor contains data
   SCAN
      ...
   ENDSCAN
   *!* and close the cursor
   USE IN c_report
ENDIF
Diederik Vermeeren
verm1864@exact.nl
 
Your code suggest that you're not even using the cursor you created. The data you're working on seems to be in a table called back_report. So why not work directly on the table using 'jonscott8' date suggestion and a replace command.

ie

Replace all back_report.orddate with back_report.orddate + (7-dow(back_report.orddate,7))

Hope this helps

Gem aka &quot;the new KID&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top