Reputation: 1
i'm new to PowerBuilder 10.5 i'm trying to create a cost application , i want to autocomplete the row when i pick a enter image description herematerial from a DDDW i want to auto fill the price & unit. there are 2 tables 1Material - Unit - Price 2- Itemname DDDW - Quantity - Unit - Price i did it on MSaccess but i don't know how to code it on PowerBuilder on access the code was
Private Sub ItemName_AfterUpdate()
Unit = ItemName. Column(2)
Price = ItemName. Column(3)
End Sub
how can i do it in PowerBuilder
Upvotes: 0
Views: 1072
Reputation: 2397
If you have included the quantity and price with the data retrieved as part of the datawindow object you are using for the DDDW you can access it without another database call. Something like this (in itemchanged event):
datawindowchild dwc
string ls_name
long ll_row
IF Upper(dwo.Name) = "ITEM" THEN
GetChild("item", dwc)
ls_name = data
dwc.SetFilter("name = '" + ls_name +"'" )
dwc.Filter( ) // filter to specific row in dddw
ll_row = dwc.RowCount( ) // How many? Use the last one.
if ll_row > 0 then
SetItem(row, "cost", GetItemDecimal('cost', ll_row))
SetItem(row, "amount", GetItemDecimal('amount', ll_row))
end if
end if
Upvotes: 1
Reputation: 395
Code the following in the ÌtemChanged
event of your detail datawindow (of course the code must be adapted to your specific situation):
decimal ld_qty, ld_unitprice
if Upper(dwo.name) <> 'ITEM' then
return
end if
select qty, unit_price into :ld_qty, :ld_unitprice from your_table where your_table.key = data;
dw2.SetItem(row, 'your_dw_col_qty', ld_qty)
dw2.SetItem(row, 'your_dw_unit_price', ld_unitprice)
Upvotes: 1