Ask Your Question
0

How do I get the lookup to show a table field other than the pk?

asked 2016-07-19 19:19:39 +0100

Tyler gravatar image

I have a table called wotbl with a field called plbmid and another table called comtbl. The comtbl has a list of Plumbers, and other construction companies, and I want a drop down picker to reflect the Company Name in the wotbl plbmid field, What I get is the Primary Key in that field. How do I assign the label to show me the Company Name in the drop down?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2016-07-20 03:43:35 +0100

Ratslinger gravatar image

A sample is attached demonstrating the following. There are three scenarios. The forms are "Participants", "Participants2" and "Participants3". each form uses related tables - "Participants"(your 'wotbl') and "Companies"(your 'comtbl').

The Participants form gives you just what you asked for in your question - the Name vs the ID in the dropdown. The problem here is since the key field is different you can have multiple companies with the same name. This can be viewed in the dropdown list and the Companies table.

The Participants2 form uses the Name as its' Primary key. Now if there are multiple companies with the same name, something must be added to the Name (used the city in the example) for it to be unique.

The Participants3 form is the same as the Participants form except the Name inserted into the Participants3 table is a concatenation of the Company Name, Address and City.

All dropdowns work basically the same. Look at the dropdown list box properties in the Data tab. The Type of list contents is SQL and the List content is the selection which is aided in generation by choosing the ellipsis (...) at the far right.

There are certainly many other ways to go. Wanted to present some potential problems and choices.

ListBoxAltSource.odb

edit flag offensive delete link more

Comments

Sorry I have not gotten back to this. The last question I asked I got email notifications when answers came in, atleast I think I did, anyway didn't get any notifications so I did not check until now. I solved the issue with a select statement but apparently because I am linked to a Postgre database things don't work quite the same way as in a HSQL database. So I had to define the relationship in the SQL Select statement and it does work now. However I also have other issues.

Tyler gravatar imageTyler ( 2016-07-21 18:22:17 +0100 )edit

I have more questions related to this, should I start more forums or ask here? After I got things working in HSQL I moved over to postgreSQL, and it is starting to give me some errors.

Tyler gravatar imageTyler ( 2016-07-22 20:20:33 +0100 )edit

Based upon your comment, best to start a new question. Please include your LO version, OS and the DB you are using. Most times this comes into play.

Ratslinger gravatar imageRatslinger ( 2016-07-22 20:37:44 +0100 )edit

ok, my next question should be here. https://ask.libreoffice.org/en/questi... I hope it is clear. Cheers

Tyler gravatar imageTyler ( 2016-07-26 15:12:08 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-07-19 19:19:39 +0100

Seen: 338 times

Last updated: Jul 20 '16