RunTime Error Understanding

Hello! Please help me understand or fix this error:

I am working on a like inventory list. If I click add to cart, the products will add to their respective list views. but then if I click the name of item, and then click remove, that error appears. What can I do?

My blocks:

*Update: But if I have two items in the list and I try to remove the other one, the error does not appear

Like you are using the SelectionIndex from the three ListViews, you must have selected one item on each of the three ListViews. If not, the SelectionIndex of that ListView will be 0.

Or if the elements in three ListView are paired (and with the same elements number), you can use one of them like "master" and assign to the SelectionIndex of the others the same index so, you will need to select an item only in the first one. Something like this:

Anyway, maybe you could rethink the way you organize the data, and create a list of repository items, each item having three elements: item, price and quantity.

To manage three paired lists looks like more complicated.

I solved it, thank you! But I have another question.

I am already at my most 70~80% progress on this system. So I have this where I can pick the product I input from the inventory. It is a product inventory where I can input the products I have, as well as create lists to track down transactions and save them. That is why the number of stocks being updated at real time is important

If I am making a list, I choose the product, set quantity and such. SO in the video, you can see I have a list. My concerns are:

  • If there is an item with same name, is it possible to just add/update the quantity and total price instead of having two elements of them?

  • The Plus button cannot be click if it reached the number of available stocks, but I have not yet it done where the number of stocks is also updated from the database, that is why I have multiple lists that already exceed the number of stocks

  • When I go to another screen, the list disappears. Though I am planning to put another button at the bottom most part, which are: SAVE TRANSACTION and DELETE TRANSACTION. If I save transaction, I will save it and I can view it in the inventory using a list view (I think?) But the number of stocks should also be update from the database and that is my problem

This is my blocks:

This is my inventory:

And blocks for inventory (if needed)

If you are referring the list of selected items (where you are handling three ListViews) then you can search in the list of items if the new one already exist. If yes, get its index and replace the same price[index] and same quantity[index] with the sum of the already existing and the new one.

You need to check if in the list of the selected items you already have any similar item. If yes, get the quantity and the available items would be the total minus this already selected. This is the number you need to check in the Plus button.

In the Initialize block of that screen set the ListView.Elements to the GetValue(tinyDB) of the corresponding tag (empty list like default value). The same for the three ListViews.

Ill try, thank you!

Just like this?

(Not tested)

It would be something like this. Search in the list with the already selected items if the new one already exists. If yes, get its quantity (from the list of quantities and using the same index). Then, the number of items you can still add would be the "Total - Already_Selected"

Ah, why did I chose this system to make. I am having a mental breakdown haha. Thanks for your help!