SQL.Initialize("/storage/emulated/0/Folder/DataBase/", "DB.db", True)
Dim CursorProducts As Cursor
CursorProducts = SQL.ExecQuery("SELECT Code, Company, Description, Category, Units, PriceListA, PriceListB, PriceListC FROM Products")
Dim ACount As Int
Dim BCount As Int
ACount = BCount = 0
For i = 0 To FOrdersLV.GetSize - 1
Code = FOrdersLV.GetPanel(i).GetView(0)
QtyEdt = FOrdersLV.GetPanel(i).GetView(4)
For j = 0 To CursorProducts.RowCount - 1
CursorProducts.Position = j
If Code.text = CursorProducts.GetString("Code") Then
Company = CursorProducts.GetString("Company")
If Company = "A" Then
AVar = "True"
ACell.InitializeText(0,18 + ACount, QtyEdt.text)
ACount = ACount + 1
Else If Company = "B" Then
BVar = "True"
BCell.InitializeText(0,18 + BCount, QtyEdt.text)
B_WOrdersheet.AddCell(BCell)
BCount = BCount + 1 'Probably the cause of the error
End If
Next
Next
If AVar = "True" Then
A_WritableWB.Write 'No Problem Here
A_WritableWB.Close
Else
A_WritableWB.Close
End If
If BVar = "True" Then
B_WritableWB.Write 'Error Happens Here
B_WritableWB.Close
Else
B_WritableWB.Close
End If