Hi, Marc. Here's a WAG < s >
Does it help to prefix all the field names with the table names? I guess I've always heard that that is safest. Since it works in the command window, you're sure of which tables are opened where. When you just execute the sql statement I believe you have no assurance as to which table is open where.
>
>select virtual.*, iif(V_Weight=0,0,v_Value/v_weight) as price;
> from Virtual,Stock,Sale;
> where stk_Parcel=V_Stock;
> and sal_Docnr= stk_docnr;
> and V_Box= cKey;
> and V_Status= hStk_Sale;
> into cursor glSold
>
>
>This works 1) when I open the files and executed it in the command window. 2) from the program if I leave out the iif statement, and 3) it worked yesterday :).