[Solved] Sql Combo Box info needed

Creating and using forms
Post Reply
widowmaker
Posts: 21
Joined: Mon Apr 27, 2020 10:51 pm

[Solved] Sql Combo Box info needed

Post by widowmaker »

I would like to get some feedback on if it is possible to create a sql statement that I could use in a form to create a combo box that would display data from a
table named “Inventory” containing 3 fields. The field names are
“InvID”,
“Code” and
“ItemName”.

I would then like to be able to click on ONE Item in the “code” field
and have the “InvID” for that selection placed into a
“ItemID” field located in a subform or master form linked to a “Order” table.

Thank You
Last edited by widowmaker on Wed Jun 10, 2020 2:11 pm, edited 1 time in total.
LibreOffice 6.0.7.3 on Linux Mint 19.3
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Sql Combo Box info needed

Post by Villeroy »

This is what a list box does. A combo box is just an ordinary text box plus auto-complete.

Data properties for a working list box
Linked field: ItemID [the column where we write to]
Command type: SQL
Command: SELECT "code", "InvID" FROM "Other Table" ORDER BY "code" ASC [first field is visible, second field is written to linked field]
Bound field: 1 [which is the index of the second one, the first field has index 0]

If you need many similar list boxes like this, you may save the SQL as a query and refer to that query. The result is the same but easier to repeat.
The first field can also be a concatenation such as "Surname" || ' ' || "Forename"
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
widowmaker
Posts: 21
Joined: Mon Apr 27, 2020 10:51 pm

Re: Sql Combo Box info needed

Post by widowmaker »

widowmaker wrote:
I would then like to be able to click on ONE Item in the “code” field
and have the “InvID” for that selection placed into a
“ItemID” field located in a subform or master form linked to a “Order” table.

Thank You
This project is for a handicapped person that can only use one hand, so it is vital that I come up with a combo or list box that will make it possible for a user to enter data by simply clicking a mouse button in a drop down list. I have built list and combo boxes in Access, but since that is not an option for person I am building this for, any info on how to do this would be greatly appreciated.
Thanks
LibreOffice 6.0.7.3 on Linux Mint 19.3
UnklDonald418
Volunteer
Posts: 1549
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Sql Combo Box info needed

Post by UnklDonald418 »

Look at this example
[Example] Invoice Forms (without macros)
Here are some other resources that might you find helpful
A tutorial Combo vs List Box
and another example Cascading list boxes with and without macros
Then if you have any specific questions we can try to help you from there.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Sql Combo Box info needed

Post by Villeroy »

The handling is the same. The functionality is different. Both, listbox and combo, come in two different appearances with or without drop-down button. The attachment is a mockup demonstrating two listboxes and two combo boxes.
Attachments
ListCombo_Mockup.odt
(16.05 KiB) Downloaded 263 times
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