Here we go again
I am trying to test a table to see if a particular product has already been entered if it has then 2 column values are adjusted and the row is updated.
if the product is not in the table then the row is added.
However the code does not work. Could someone explain the error in my logic
StblOrders.Filter("ProductCode='ProductCode'")
If StblOrders.RowCount=1 Then
Qty=StblOrders.Cell("Qty",1)+Qty
StblOrders.Cell("Qty",1)=Qty
StblOrders.Cell("Price",1)=ProdPrice*Qty
Else
StblOrders.AddRow (VanNo,CustCode,TrxNo,ItemNo,Time(Now),Date(Now),ProductCode,ProdPrice,Qty,TrxType,ProdName,ProdPrice*Qty)
End If
StblOrders.Filter("")
i have checked this thread http://www.b4x.com/forum/questions-help-needed/5104-finding-data-table.html
and adapted the code to the following which does work but i would still like to know why the above does not work
Sub ProductExist
Dim i
i=0
If StblOrders.RowCount>0 Then
Do
If ProductCode=StblOrders.Cell("ProductCode",i) Then
Qty1=Qty
Qty=StblOrders.Cell("Qty",i)
Qty=Qty+Qty1
StblOrders.Cell("Qty",i)=Qty
StblOrders.Cell("Price",i)=ProdPrice*Qty
Return True
End If
i=i+1
Loop Until i=StblOrders.RowCount
End If
Return False
End Sub
Thanks
Joe
I am trying to test a table to see if a particular product has already been entered if it has then 2 column values are adjusted and the row is updated.
if the product is not in the table then the row is added.
However the code does not work. Could someone explain the error in my logic
StblOrders.Filter("ProductCode='ProductCode'")
If StblOrders.RowCount=1 Then
Qty=StblOrders.Cell("Qty",1)+Qty
StblOrders.Cell("Qty",1)=Qty
StblOrders.Cell("Price",1)=ProdPrice*Qty
Else
StblOrders.AddRow (VanNo,CustCode,TrxNo,ItemNo,Time(Now),Date(Now),ProductCode,ProdPrice,Qty,TrxType,ProdName,ProdPrice*Qty)
End If
StblOrders.Filter("")
i have checked this thread http://www.b4x.com/forum/questions-help-needed/5104-finding-data-table.html
and adapted the code to the following which does work but i would still like to know why the above does not work
Sub ProductExist
Dim i
i=0
If StblOrders.RowCount>0 Then
Do
If ProductCode=StblOrders.Cell("ProductCode",i) Then
Qty1=Qty
Qty=StblOrders.Cell("Qty",i)
Qty=Qty+Qty1
StblOrders.Cell("Qty",i)=Qty
StblOrders.Cell("Price",i)=ProdPrice*Qty
Return True
End If
i=i+1
Loop Until i=StblOrders.RowCount
End If
Return False
End Sub
Thanks
Joe
Last edited: