Page 1 of 1

[Solved] Drop down list to populate form

Posted: Sat Apr 25, 2020 9:45 am
by Mickey12
Good Morning, I am trying to create a drop down list of client's name to select from which when selected would then populate the fields in the form.
The drop down list in the current form was very kindly created for me in this forum.
I thought I would be able to use that as some sort of guide to make the second list list but it is beyond my capabilities.
Thanks in advance

Re: Drop down list to populate form

Posted: Sat Apr 25, 2020 12:44 pm
by Villeroy
There is a built-in filter which gives you list boxes for free. It goes like this:
Open the form for editing and get the properties of the name box (Ctrl+Click>Edit>Control... or right-click in the form navigator).
On the "Data" tab check "Filter proposal".
Turn off edit mode to test this setup.
-----------------
Push "Form based filter" on the navigation bar.
Another small toolbar with a small window pops up. The name box turned into a listbox
Select a name and leave the filter form mode using the small toolbar's "Apply" button.

Re: Drop down list to populate form

Posted: Sat Apr 25, 2020 3:59 pm
by Mickey12
Thanks Villeroy. I think I am jumping the gun here. The idea is to call up names already in the clients table (or enter new record), but I see I am able to have more than one Charlie Parker! Perhaps I should post this in a separate thread?

Re: Drop down list to populate form

Posted: Sat Apr 25, 2020 4:42 pm
by Villeroy
Delete all rows from the persons table.
Open the table in edit mode (right-click>Edit...).
1. Mark every column as "Entry required" where saving a record without that column value makes no sense. I would suggest "First Name" and "Last Name". Now you can't store any row without giving a first and last name at least.
2. While having the table in edit mode, menu:Tools>Index Design...
2.1. Create a new index, name it as "Unique_Names" or similarly
2.2. add the two columns "First Name" and "Last Name"
2.3. mark that index as unique.
2.4. Save that index. this would fail if there were duplicates violating the new index, therefore I recommend to delete all test data.
3. Save and close the table.
Now you can not enter duplicate pairs of "First Name" and "Last Name" anymore.

Re: Drop down list to populate form

Posted: Sun Apr 26, 2020 11:09 am
by Mickey12
Hi Villeroy Thanks very much. I made the changes ok. I had to delete the relationships first before I could delete the rows in the client table, but now when I redo the relationship
I notice that the IDCLIENTS to CID relationship is no longer a 1 to many. Is this ok?
Thanks

Re: Drop down list to populate form

Posted: Sun Apr 26, 2020 1:46 pm
by Villeroy
Go back to the initial version attached to this topic.
Keep the relations.
Delete the data from the n-side first, that is all records in "Clients_Tags".
Once the clients are no longer referenced from some other table, you can delete them from the 1-side of the relation, that is the "Clients" table. This is what referencial integrity is about. When you double-click the relation line in the relations editor, you find option "Delete cascade" which delete the 1-side data when deleting data from the n-side. I would try to not use this.

Re: Drop down list to populate form

Posted: Sun Apr 26, 2020 4:27 pm
by Mickey12
Ouch! Totally lost now. I deleted all the client records from the Clients_Tags table as well as the records from the Clients table.
I still cannot get n to 1 in the Clients to Client_Tags tables

Re: Drop down list to populate form

Posted: Sun Apr 26, 2020 4:58 pm
by Villeroy
There is still one record left in the C_T table while the C table is empty. Therefore the CID in the C_T table has no matching ID in the C table so the relation would be invalid.

Re: Drop down list to populate form

Posted: Sun Apr 26, 2020 6:21 pm
by Mickey12
Ha! It all works. Thank you so much. Steep learning curve here.

Re: Drop down list to populate form

Posted: Sun Apr 26, 2020 7:36 pm
by Villeroy
How to delete all rows from table A, then B quickly:
menu:Tools>SQL...

Code: Select all

DELETE FROM "A";
DELETE FROM "B";
[Execute]
menu:View>Refresh Tables