Question about implementation

The user works on a window where the data from a SQLite file is displayed as List.
A click in an entry opens another Window and show the selected entry as a Record view.
This works file, I asked that Record using its Unique ID.
So, the RecordSet have only one Record.

But, How do I move to the Next or Previous Record ?

AFAIK, there is no “Position = Unique ID” property as with BinaryStream.

Go to the next record in the list, get its unique id and search for that id in the table and display the data.
Some checking (first/last/ selected row) should be done, too.

Alternate way: fill an array with the unique ids while populating the list and use those values to make a back/forward button….

Put the unique id in the rowtag for the row. Simples.

Not exactly sure what you are asking but it sounds like in one window you have a list of database records in a listbox. When the user clicks on a specific entry you show that database record in a window for editing (form window). Now you want to navigate to next database record from that form window by using a next or prev button?

If that is the case, there are multiple ways to achieve this. You could define two properties of the of the form window, one as selected rowID or recordid (integer) the other is a rowset or recordset. When the user selects the item in the first window’s listbox, pass the rowID and existing recordset to the window and open. Then implement the prev and next buttons, getting the records from the rowset.

As Tim mentioned above, put the rowID or unique ID in the rowtag of the listbox.

Not sure if this is what you are asking…

1 Like

Here’s a shema of the target design:

Explanations:

The image reflect how the project works (the part where the question arise).

When the application is fired, a “Welcome” window is displayed and I store some data extracted from the data base (Number of people in the db, In and Out; last access date).

A click or key press close this window and display the View by list window for user reading.

When the user want to watch the full Record, he double click in an entry from the ListBox (in the View by List window),

The View by Record window is displayed. In its Open Event, the Unique ID of the selected record (stored in the ListBox RowTag) is used to display the whole Record in the window so the user can read each lines from the Cells where more than one line exist (just like the Comments fields in the shared image.
The user can Add, Remove and Modify a Record in the View by Record window.

I think, it is easier for the user to be able to navigate through the data base when in that mode.

But, excepted for MoveToFirst and MoveToLast (already implemented), I have no command to go to the next Record because there is no Position like in BinaryStream, and I do not have a RecordSet to navigate from the currently displayed Record (the RecordSet holds only one Record…).

What I started to think (either by my own or because of one answer here, I may:

Read for a Record by its Unique ID in a Loop:
a. So, Add 1 to the current UniqueID,
b. Ask for that Record,
c. Loop if the RecordSet is Nil (or empty or…) and go back to dot & above)

Once a Record is read or the Last Record reached, display it.

Same (except remove 1 to the current UniqueID and loop back)…

Are-you OK with that or did you have a better or an alternate design to achieve that goal ?

PS: in the image, I set two colors (background) to mimic a different window; there was no need to set a background color for the ListBox…

when you do the query and read all the records to put them in the listbox, can’t you write the ids into an array and use the array and a current index to handle it all? I then always put the data into objects of classes corresponding to the records…

When populating the listbox, store the unique id of each record in an array - so you can use this array to navigate.

Put the unique id of each row in the RowTag for the row.

1 Like

Another way is to have one window, in the top you have the list view and the bottom shows the details of the selected row. whenever you change a row it will display the details below. All it needs is an insert and a delete option for a row.