thank you!
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
thank you!
@ 540, 20 BUTTON "SAVE" SIZE 150,30 PIXEL OF oDlg ;
ACTION ( AEval( aItems, { |o| o:Save() } ), oDlg:End() )oBrw:Age:bOnChange := { |oCol, nOldVal| oBrw:VarPut( oCol:Value * <yourcalculation> ) }
We can use oBrw:QtyOrd, if one of the column header is "qtyord"
This returns column object
Can you please give me a list of all your headers and tell me your formula in terms of "headers" as if Headers are the variables.
Then I will suggest the solution, with proper explanation
Is it ok?
All the following expressions return the column object:
oBrw:aCols[ <nCurrentlyVisibleOrde> ] // not recommended because at runtime we do not know which colums is where
oBrw:<cheader>
oBrw:oCol( "cheader" )
oBrw:oCol( <nCreationOrder> )
Once we have the column object,
oColObject:Value --> gives the value
oColObject:VarPut ( uNewValue ) not only assigns the new value but also adjusts totals, writes data to table, and everying else.
aItems:= oSalesOrder:aItems // use a copy of the line-items
@ 3,1 XBROWSE oBrw OF oDlg ;
DATASOURCE aItems ;
COLUMNS "Itemno","Descrip","Cost","Qtyord","ExtPrice";
HEADERS "Item No", "Description","Cost","Qty Ordered","Total" ;
COLSIZES 50,140,70,70,70 ;
PICTURES "999";
SIZE 300,130
//COLORS CLR_WHITE, CLR_BLUE
oBrw:nRowHeight := 25
oBrw:lRecordSelector := .f.
// oBrw:nStretchCol := STRETCHCOL_LAST
oBrw:nRowDividerStyle := LINESTYLE_LIGHTGRAY
oBrw:nColDividerStyle := LINESTYLE_LIGHTGRAY
oBrw:lFastEdit := .T.
oBrw:aCols[ 4 ]:nEditType := EDIT_GET
// Update line item total and sales order total
// Errors out with: Error description: Error BASE/1004 Message not found: TXBROWSE:QTYORD
//msgInfo( oBrw:Qtyord, "oBrw:qtyord") // errors out
oBrw:qtyord:bOnChange := { |oCol| oBrw:extPrice:VarPut( oCol:cost * oCol:qtyord ) }
oBrw:nColSel:= 4 //oBrw:oCol( "QtyOrd" ):nCreationOrder
oBrw:CreateFromCode()INVNO C 8 0
INVDTE D 8 0
CUSTNO C 4 0
ITEMNO C 6 0
DESCRIP C 20 0
COST N 7 2
RETAIL N 7 2
PACK N 4 0
SALEQTY N 1 0
UOM C 2 0
QTYORD N 3 0
QTYSHP N 3 0
EXTPRICE N 8 2
CLASS C 1 0
TAXABLE L 1 0
DEPT C 1 0
ARTYPE C 1 0
PLU C 11 0
Record length: 96oBrw:QtyOrd:bOnChange := { | oCol | oBrw:extPrice:VarPut( oCol:Cost * oCol:QtyOrd ) }
COLUMNS "Itemno","Descrip","Cost","Qtyord","ExtPrice";
HEADERS "Item No", "Description","Cost","Qty Ordered","Total" ;@ 3,1 XBROWSE oBrw OF oDlg ;
DATASOURCE aItems ;
COLUMNS 4, 5, 6, 11, 13 ; // "Itemno","Descrip","Cost","Qtyord","ExtPrice"
HEADERS "Item No", "Description","Cost","Qty Ordered","Total" ;
COLSIZES 50,140,70,70,70 ;
PICTURES "999", nil, "9,999.99", "999", "99,999.99" ;
SIZE 300,130
oBrw:QtyOrdered:bOnChange := { |oCol| oBrw:Total:VarPut( oBrw:cost:Value * oBrw:QtyOrdered:Value ) }ItemNo Description Cost QtyOrd ExtPrice
3 TLINEITEMS
4 TLINEITEMS
5 TLINEITEMSIs it possible to make a small sample and send to my email including the dbf?
Looks like I am unable to understand your exact requirement correctly.
nageswaragunupudi[at]gmail[dot]com
Nages,
I am working on that right now.
James
Nages,
Solved!
Originally this was the suggested code for updating the Total field:
oBrw:QtyOrdered:bOnChange := { |oCol| oBrw:Total:VarPut( oCol:Cost:Value * oCol:QtyOrdered:Value ) }
However the above errors out.
This is working:
oBrw:QtyOrdered:bOnChange := { || oBrw:Total:VarPut( oBrw:Cost:Value * oBrw:QtyOrdered:Value ) }
It seems you don't need to use the column object ( oCol ) at all.
Thanks for all the help.
James