Question : Looping thru 90 codes

I need to query up 90 family codes. Right now I started to SQLexec() each one one by one because (still learning) I need to capture the code, year, and add up all 12 months as a sum() as total

So I was thinking I could just loop throught it? It would just replace the family code on each pass? Create a varible for the code but then I would have to load/ store all 90 some where first then go thru the second step of creating the 90 corsors?

Answer : Looping thru 90 codes

The you dont need FOR loop but you have to replace it by SCAN loop and the command

lcYourCode =

must be completed from the cFamily cursor:

SELECT cFamily
SCAN
  lcYourCode =  cFamily.Code  
  lcSQL = "SELECT * FROM YourTable WHERE FamilyCode = ?lcYourCode"
  lnRetVal = SQLEXEC(lnSqlHandle, lcSQL, "cResult")
   
  IF USED("cAllResults")
    SELECT cAllResults
    APPEND FROM cResult
  ELSE
    SELECT * FROM cResult INTO CURSOR cAllResults NOFILTER READWRITE
  ENDIF
ENDSCAN

Random Solutions  
 
programming4us programming4us