Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sum and replace
Message
From
22/11/2006 09:26:04
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01171725
Message ID:
01171736
Views:
11
hi,
thank you for reply,
yes my mistake i mean .
**stk_opbl from SELECT str_nmbr,stk_name,stk_clas,stk_code,stk_opbl FROM **stk_clas ;
about 55 and 44 i need to sum at one field
SUM trn_qnty for trn_typ=1 TO m.in1
SUM trn_qnty for trn typ=44 TO m.out1
sum trn_qnty for  trn_typ=55 TO m.out2
m.tot=m.out1+m.out2
   replace newfield as(insert1) WITH m.in1
   replace newfield as(outitem) WITH m.tot
   replace newfield as(balance) WITH (m.in1 +stk_opbl)-m.tot
  else
   replace newfield as(insert1) WITH 0
   replace newfield as(outitem) WITH 0
   replace newfield as(balance) WITH 0
 ENDIF
ENDSCAN
thanks.

>>hi all,
>>
>>i need help to fix this code under ,
>>
>>**this part it works fine
>>SELECT str_nmbr,stk_name,stk_clas,stk_code,stk_opbl FROM stk_clas ;
>> WHERE str_nmbr =thisform.text1.Value AND ;
>>  BETWEEN (stk_clas,thisform.text4.Value,thisform.text5.Value);
>>  INTO CURSOR aa
>>  brow
>>
>
>First, you may have a problem here with the "Thisform...." reference in the call without using () around the control. Otherwise, the SQL will try to interpret the Thisform. as an alias as part of the SQL, so either use (), or move to variables...
>
>
>select fld1, fld2, fld3... from stk_clas;
>  where str_nmbr = ( Thisform.text1.value ) and ;
>  between( stk_class, ( Thisform.text4.value ), (Thisform.text5.value));
>  ...
>
>OR
>
>lnFromStockNumber = Thisform.text1.value
>lnStockClassFrom = Thisform.text4.value
>lnStockClassTo = Thisform.Text5.value

>
>select fld1, fld2,...
>   where str_nmbr = lnFromStockNumber;
>     and between( stk_class, lnStockClassFrom, lnStockClassTo )...
>
>
>
>
>
>
>>**this code need your experience
>>
>>SCAN  FOR trn_rqb3.str_nmbr=aa.str_nmbr AND trn_rqb3.stk_code=aa.stk_code
>> IF FOUND()
>>   SUM trn_qnty for trn_typ=1 TO m.in1
>>   SUM trn_qnty for trn typ=44 AND trn_qnty for  trn_typ=55 TO m.out1
>>   replace newfield as(insert1) WITH m.in1
>>   replace newfield as(outitem) WITH m.out1
>>   replace newfield as(balance) WITH (m.in1 +stk_opbl)-m.out1
>>  else
>>   replace newfield as(insert1) WITH 0
>>   replace newfield as(outitem) WITH 0
>>   replace newfield as(balance) WITH 0
>> ENDIF
>>ENDSCAN
>>
>>*  REPORT FORM myreport
>>
>>
>>thanks
>
>Not positive about what your trn_rqb3 table is, but it looks like your trying to get a sub-total per unique combination by a stock number and code based on matched entries into the cursor of "aa" you did in the first step. Please clarify. It looks like you are using the "trn_typ" field as a qualifier, but what column are you trying to sum, or is it you just want a count of records. Also, your condition of trn_typ=44 and trn_typ=55 would ALWAYS fail as one field (such as numeric) could never be equal to both... what I think you mean is if ( trn_typ=44 OR trn_typ = 55) then sum (or count) to the m.Out1 field for later storage. Finally, where is the stk_opbl column coming from (which looks like it implies Open Balance).
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform