The creates a variable local to the event this code is in. You need to make db a property of the window or in a module. That will make it available to all the events of the listbox.
And what hasn’t been stated yet is a RowSet is single use, which is why you have to go back to the database each time.
I think you have db as a Window property and you are creating another db with this code
Var db as new SQLiteDatabase
please comment/remove that line and try again.
What is happening is that you have a Window property (db) and then you are creating a ‘temporary’ property by doing the Var db as new SQLiteDatabase. That temporary property is destroyed when the event finishes.
Edit: if you load the Examples - Database - SQLite - SQLiteExample.xojo_binary_project you can see that the example uses db in App and then App.db for the code. That helps to have the db defined in one place and no matter if you have 2 windows (like in the example) both point to App.db. Reviewing that code can help you.
And, yes, I saw that code, where db is defined as a property of the application. I did try it, but got errors (probably because same duplicate definition). I will go back to it, as I think it is a good place to put the property. Thanks again.
You might be right if the number of rows is not too large. One way you could handle it is create a class that could hold the values of the row, save an instance of that class in the RowTag and just access it when you need it.