Without allt() no records are selected (struggled over that one already) and I wondered about the logical for .wrk_stat, that was what query wizard stuck in there. Thanks for showing me what I missed. I'll give it a try.
>You didn't specify the field name in the textbox value assigment.
>BTW, You don't need to compare result of 'Cdm30wrk.wrk_stat = "A-ACCTNG"' to the .t. because it's already logical value. There's also no need to ALLTRIM(Cdm30wrk.cmp_name) because foxpro compares the string on the left to the lenght of the string on the right.
SELECT SUM(Cdm30wrk.wrk_tlamt) AS LastYearSales;
> FROM classicdb!cdm30wrk;
> WHERE Cdm30wrk.wrk_stat = "A-ACCTNG" ;
> AND Cdm30wrk.wrk_page = 1;
> AND Cdm30wrk.cmp_name = lcThisClient;
> AND YEAR(Cdm30wrk.date_updt) = ldLastYear;
>into cursor curLastYearSales
>thisform.pgfClientDetails.pagAccountDetails.txtLastYearSales.value = curLastYearSales.LastYearSales
>
>>Please show me why this code returns what it does.
>>
>>local ldLastYear, lcThisClient, curLastYearSales
>>
>>***
>>
>>ldLastYear = YEAR(DATE()) - 1
>>lcThisClient = thisform.cboClientName.Value
>>
>>
>>SELECT SUM(Cdm30wrk.wrk_tlamt);
>> FROM classicdb!cdm30wrk;
>> WHERE Cdm30wrk.wrk_stat = "A-ACCTNG" = .T.;
>> AND Cdm30wrk.wrk_page = 1;
>> AND ALLT(Cdm30wrk.cmp_name) = lcThisClient;
>> AND YEAR(Cdm30wrk.date_updt) = ldLastYear;
>>into cursor curLastYearSales
>>thisform.pgfClientDetails.pagAccountDetails.txtLastYearSales.value = curLastYearSales
>>
>>This code is in the init of the form. Optimistic locking, table buffered private data session.
>>Instead of a currency amount I get F for any client I select on the form. I put a thisform.refresh in the LostFocus of the combo that selects the client to view.
>>
>>I tested the query (without form related variables) in the command window with a hard coded client selection and the query returned 1 record, a nice numerical amount. What is different? Is the Init the wrong place to place the code? Have I done something wacky with the assignments?
>>
>>Regards and TIA,
>>Matthew
Opportunity is missed by most people beacuse it is dressed in overalls, and looks like work --- Thomas Edison