How to generate and display fields from database

I have a window that allows a user to input information that they want to add to a list from a field on the screen.
Then I generate a database to create field form the items in the list. These fields are going to be the headings into which data will be stored once the database is created.

So my problem is, what is the best way to now automatically generate a window that allows me to display labels and text fields for data to be entered so that it can be stored in the database in the fields I have created?

Does this window need to be generated on the fly ?
ie/ read the db table description now make a window + labels & fields in a running program ?

I don’t need to generate the window on the fly as such. I just need to be able to load the labels and fields into the window in some sensible way, then take the data and put it into the database.

Of course, being able to do the window as well would be very cool.

You could try Argen which is now open source. It should get you up and running.

Argen is much more complicated than what I need. I just need to figure out the underlying approach that underlies Argen, without generating objects - it is only one window and the rest of the code is sorted.

Argen just does it pretty generically

That said how many tables might this be ? 1, 10, 100 ?

For a single table its not so bad - but doing it generically for a bunch of different tables get more complicated since you need to

  • read the table definition (to get the columns) which might tell you how many labels you need
  • create labels for each
  • create a text entry field for each
    along the way you want to put a tag on each to know which data field on the layout corresponds to each database column

it starts to get kind of messy

Hi again
Sorry, I wasn’t clear enough → Argen as such isn’t the way to go as the sqlite database is generated in code and will be different each time it is generated.
To be more specific. I have written an application that generates random allocation to different treatment arms for a clinical trial. The next step is to ask the user what measurements they want to make and what treatment outcomes they are looking at, This information is added to a listbox. Once the user is satisfied with this, an SQLite database is generated. In the next step, the fields that are constant are displayed in a listbox. What I want to do next is to display the fields from any individual record he database in a window so that those fields that are empty can be completed (measurements, outcome measures). The structure of the database will vary according to the decisions made in a previous step.
Hence my desire to know how to identify the structure of the database and to display the column headings on the window by code, and place textfields next to them for data entry.
I am looking at the Xojo documentation, but would appreciate any guidance in this area. It is an interesting challenge.

I guess what you are suggesting is to dig int the Argen code to see how it is fine there, but I am finding that challenging.

Argen is complex but it needs to do everything in a very generic way

For a single table you can get the names & types of the columns using the TableColumns method

To set & add labels & text fields & such you can use a control set
That allows you to dynamically add as many instances as you want
see UserGuide:Desktop Control Sets - Xojo Documentation

a quick and dirty sample
this creates a table with a random # of columns then sets up a window with labels & textfields for them
its missing a LOT but it gets you the idea

Thank You!
That is exactly the pointer I needed. I was able to generate an editable listbox on the fly, but I don’t think that is the best approach.
If I use a window with labels and text fields for data entry, I can control the environment much more easily. I really appreciate your help with this. I will be using the application in my research, but it has the potential to provide a generic solution for anyone doing comparative studies.

the method to use also depends on the number of records to display.
if you reach 500-1k records, the listbox without a paging system may become very slow.

Thank you JeanYves,
That should not be p roblem. I plan to place a limit on the number of fields to be displayed/entered.

Thanks again for your help.
I now have a fully functioning app on the App Store that uses this approach to create a database on the fly, interrogate its structure and display the data for entry and storage. I have also written an example app that just displays the fields from an SQLite database for data entry and storage which I can send to anyone interested. I have extended your ‘quick and dirty example’ and can display up to 40 database fields in a listbox, open a window and display them for data entry and storage.

take a look at my “vnschinook” app to see what can be done with multiwindow database app.