All my tables were always open - I checked all that out completely. The nested structure came from the CREATE QUERY command, so I've just used it as is in my code - I'll go back and re-examine my other queries.
>I seem to remember it works when all the tables in the SQL were already open before executing the SQL. I have not experimented with the *why* success is intermittent. I just know that it will be a cold day in August in Dallas before I use a nested join.
>
>>Thanks. That has solved the problem, but do you have any idea why the nested joins would work sometimes and not others?
>>
>>
>>>Start by un-nesting the JOINs.
>>>
>>>SELECT Subjects.subjcode, ...
>>> FROM attendnc ;
>>> INNER JOIN subjects ;
>>> ON Attendnc.subject_id=Subjects.subject_id;
>>> INNER JOIN enrolmts;
>>> ON Attendnc.enrol_id=Enrolmts.enrol_id;
>>> WHERE ... conditions
>>> ORDER BY Subjects.subjcode, Subjects.subject_id ;
>>> INTO CURSOR ATTTMP