Page 1 of 1

Display Name, but use ID

PostPosted: Sun Oct 07, 2018 11:15 am
by diginix
Hello,
I am new to this forum and to OpenOffice.
Sorry, I haven't found easy solution for my question, maybe not good in search ))

Here is my question:
I have 2 very simple tables.

Table "Operation"
ID, Name, ProjectID (it's for relationship with ID of second table)

Table "Project"
ID, ProjectName

In Operation form I am creating Listbox for ProjectID with data collected from "Project" Table ("ProjectName")

In the dropdown list I see Project Names. But after I choose the right name, I see just ProjectID.
I want the form to show ProjectName.

Could someone help, please?
Thanks.

Re: Display Name, but use ID

PostPosted: Sun Oct 07, 2018 5:20 pm
by Villeroy

Re: Display Name, but use ID

PostPosted: Sun Oct 07, 2018 5:35 pm
by UnklDonald418
A list box control on a Base form uses two fields, a display field and a boundfield.
The display field must appear first and the boundfield must appear second.
For instance, open the Properties: List Box dialog for your list box and on the Data tab
the Data field would be "ProjectID" from the table "Operation".
Input required should be Yes
Set Type of list contents to Sql
the List content to
Code: Select all   Expand viewCollapse view
SELECT   "ProjectName", "ID"  FROM "Project" ORDER BY  "ProjectName" ASC;

and leave the Boundfield set to 1 (changing it to anything else is futile)

Re: Display Name, but use ID

PostPosted: Sun Oct 07, 2018 8:37 pm
by diginix
Thanks,
Yes it's working fine with Listbox without Editing or find possibility
But when it can be entered manually it doesn't work correctly.
Sorry, I am using not English version of Open Office, so it's possible to make some misunderstandings with UI element names ))

Re: Display Name, but use ID

PostPosted: Sun Oct 07, 2018 10:16 pm
by UnklDonald418
I'm not sure what you mean when you say
But when it can be entered manually it doesn't work correctly.

If you are trying to add new entries into the "Project" table, that is not possible using a list box.