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