[Solved] Problem with dropdown box and relationships

Discuss the database features
Post Reply
Bjarne Kristensen
Posts: 8
Joined: Mon Mar 16, 2020 11:14 pm

[Solved] Problem with dropdown box and relationships

Post by Bjarne Kristensen »

Hi. Trying to learn about databases, and online videos are great. Now I am stuck on an issue, and can not find the methode.
I have made a very easy table, just listing some names in a imaginary comany. Then some different information about each employer.
Then, I made a form, and now I am able to toggle between the post numbers with the arrows, to see all the information for each name, as listed in each table line.
So far so good. Now, I want to be able to choose one name from a dropdown box, and the rest of the fields related to that name should change as when toggeling the post arrows in the form.
I made the field "name" into a dropdown box by first changing it to a "list-box", then choosing the right table and content in the DATA section. Now, I can choose the field to be a dropdown box. Now, I am able to use the box to choose any name, but the rest of the fields don´t change! What have I not done right? Is there some kind of connection between each name, and the rest of the info in the same line in the table I need to make?
I would realy appreciate any tip, link to earlier posts or links to videos.

To make the whole thing more complicated, the "name" field should actually be devided into two fields, First and Sir name. The best would be to have dropdown boxes on both, so that I would have to choose both first name and Sir name to be able to get information in all the other fields regarding the chosen employee.

Anyone?
Last edited by Hagar Delest on Tue Mar 02, 2021 10:01 pm, edited 1 time in total.
Reason: tagged solved.
Apache OpenOffice 4.1.7on Windows 10
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Problem with dropdown box and relationships

Post by FJCC »

Can you upload the Base file? To upload a file, click Post Reply then look for the Upload Attachment tab just below the box where you type a response.

I think it would be better to use a Combo Box for this task rather than a List Box. A Combo Box is like a Text Box with a drop down list. A List Box displays one value but sends another to the database.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Bjarne Kristensen
Posts: 8
Joined: Mon Mar 16, 2020 11:14 pm

Re: Problem with dropdown box and relationships

Post by Bjarne Kristensen »

Thank you for your reply. Tried a combo box (current), but with the same result. I can change name in dropdown box, but nothing else changes. I have tried to attach the file.
My program is in Norwegian, but that should maybe not matter when you open it in an Enlish version?
Attachments
Test.odb
(14.31 KiB) Downloaded 183 times
Apache OpenOffice 4.1.7on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Problem with dropdown box and relationships

Post by Villeroy »

Start with a combo box. A combo box is a normal text box with auto-complete function.
Source type: SQL (or Query if you store the below statement as a query)
Source: SELECT DISTINCT "name" FROM "table" ORDER BY "name" ASC (or the name of the query storing this statement)
You can enter any text into a combo box. The suggested names are the ones that already exist.

A list box would allow only items that are stored in a second table. A list box has two columns, a visible text and the other table's primary key. You select a table entry by the visible text and the other table's PK is written into this table's foreign key so you get a unique reference pointing to a distinct record of the other table.
[Example] Relations reflected by list boxes in forms

and Combo vs List Box
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
Bjarne Kristensen
Posts: 8
Joined: Mon Mar 16, 2020 11:14 pm

Re: Problem with dropdown box and relationships

Post by Bjarne Kristensen »

Villeroy wrote:Start with a combo box. A combo box is a normal text box with auto-complete function.
Source type: SQL (or Query if you store the below statement as a query)
Source: SELECT DISTINCT "name" FROM "table" ORDER BY "name" ASC (or the name of the query storing this statement)
You can enter any text into a combo box. The suggested names are the ones that already exist.

A list box would allow only items that are stored in a second table. A list box has two columns, a visible text and the other table's primary key. You select a table entry by the visible text and the other table's PK is written into this table's foreign key so you get a unique reference pointing to a distinct record of the other table.
[Example] Relations reflected by list boxes in forms
I could not make good sence of your suggestions. I think you need to make belive I am your 90 year old grandfather, and he will need to be fed this with a teespoon :-). Have you tried to open the file I uploaded and made it work? Maybee then upload the working file, with an explenation?
Will I have to first make a query, and link the form to that?
I tried to choose SQL into the Source Type, but got a feedback saying Syntax Error when trying to choose Source.
I am Norwegian, and having some trouble searching the internet for videos about this, I think because I use the wrong search words. Maybee someone can help me finding a good video?
Apache OpenOffice 4.1.7on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Problem with dropdown box and relationships

Post by Villeroy »

Videos don't teach anything (unless you are a chimp).
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
Bjarne Kristensen
Posts: 8
Joined: Mon Mar 16, 2020 11:14 pm

Re: Problem with dropdown box and relationships

Post by Bjarne Kristensen »

Villeroy wrote:Videos don't teach anything (unless you are a chimp).
Dear Villeroy sir! Thank you for your constructiv post. I am sorry I offended you by not understanding your sollution. I am sure you also had to learn this stuff at some stage.
Tutorial videos has actually taught me a great deal.
Apache OpenOffice 4.1.7on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Problem with dropdown box and relationships

Post by Villeroy »

You may have missed the second link Combo vs List Box which I added a few minutes after posting.
The subforum about Base tutorials contains basic tutorials, tutorials for special cases, links to other tutorials elsewhere and a subforum full of example databases.
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
Bjarne Kristensen
Posts: 8
Joined: Mon Mar 16, 2020 11:14 pm

Re: Problem with dropdown box and relationships

Post by Bjarne Kristensen »

So, I found a video !! showing me the easy way to do what I wanted. Just by using the "search" button when in the form. Easy, and no need for a dropdown box or any hocus pocus. The records show up with all connected information.
Apache OpenOffice 4.1.7on Windows 10
Post Reply