[Solved] Drop down list to populate form

Discuss the database features
Post Reply
Mickey12
Posts: 75
Joined: Thu Apr 16, 2020 3:07 pm

[Solved] Drop down list to populate form

Post 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
Attachments
Integral Health2.odb
(26.08 KiB) Downloaded 296 times
Last edited by Mickey12 on Tue Apr 28, 2020 12:14 pm, edited 1 time in total.
Open Office 4.1.7 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Drop down list to populate form

Post 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.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Mickey12
Posts: 75
Joined: Thu Apr 16, 2020 3:07 pm

Re: Drop down list to populate form

Post 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?
Open Office 4.1.7 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Drop down list to populate form

Post 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.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Mickey12
Posts: 75
Joined: Thu Apr 16, 2020 3:07 pm

Re: Drop down list to populate form

Post 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
Open Office 4.1.7 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Drop down list to populate form

Post 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.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Mickey12
Posts: 75
Joined: Thu Apr 16, 2020 3:07 pm

Re: Drop down list to populate form

Post 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
Attachments
Integral Health2.odb
(26.13 KiB) Downloaded 244 times
Open Office 4.1.7 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Drop down list to populate form

Post 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.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Mickey12
Posts: 75
Joined: Thu Apr 16, 2020 3:07 pm

Re: Drop down list to populate form

Post by Mickey12 »

Ha! It all works. Thank you so much. Steep learning curve here.
Open Office 4.1.7 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Drop down list to populate form

Post 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
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply