[Solved] ListBox in Subform

Creating and using forms
Post Reply
nstrong
Posts: 21
Joined: Thu Apr 02, 2009 11:43 pm

[Solved] ListBox in Subform

Post by nstrong »

I have created a form for inputting date for invoice. It is set up so that you can type in the clients_name into a listbox and it will pull their client _ID into its own field. In a sub-form i what to do the same thing but with product_name and product_number.

The problem is that i can not get a listbox to be set to the subform, so that i can use the wizard to set up the listbox properly. when i insert a listbox it is always set to the main form and i am unable to set the listbox to link with the subform fields. I know the answer to this must be very simple and i should not be wasting anyone's time with it, but i can not figure it out.
Last edited by nstrong on Tue May 12, 2009 6:46 pm, edited 2 times in total.
OOo 2.4.X on Ms Windows XP
User avatar
Villeroy
Volunteer
Posts: 31264
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: ListBox in Subform

Post by Villeroy »

Open the form for editing and get the form navigator from button #5 of toolbar "Form Design".
The form navigator shows the hierarchy of forms, subforms and controls. You can drag elements from one form to another if they are attached to the wrong form.
Usually a list box is bound to a numeric ID-field (field #1) while displaying a field of strings (field #0). The SQL-source of the field should be like:

Code: Select all

SELECT "DisplayField", "BoundField" FROM "Table" ORDER BY "DisplayField"
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
nstrong
Posts: 21
Joined: Thu Apr 02, 2009 11:43 pm

Re: ListBox in Subform

Post by nstrong »

I have moved the listbox into the subform as described and my code matches up with that above. but now when i go to use the listbox it is blocked out completely and does not display anything.

Could the problem be that my product_number is a text field and is not a numeric field?
OOo 2.4.X on Ms Windows XP
User avatar
Villeroy
Volunteer
Posts: 31264
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: ListBox in Subform

Post by Villeroy »

No, the field type of the bound field does not matter as long as it matches with the field type of the linked field.

The typical list box pulls two fields from a source table in order to write one value into the linked field of the underlying form.
[Source Table] >> [Displayed Field & Bound Field] > [Linked Form Field]
The user picks a value from the source table's display field (box field #0) in order to write another hidden value (box field #1) into the linked field of the form's row set.
Sometimes you want both fields to be the same: SELECT "Field X", "Field X" FROM "Table" ORDER BY "Field X"

One surprising reason why a list box may be dysfunctional is property "Drop Down". If this is set to "No" you end up with a multi-line list box being too flat to be usable. Make the box higher or turn it into a drop-down box.
Last edited by Villeroy on Fri Apr 24, 2009 1:04 pm, edited 2 times in total.
Reason: added one explanation for the A>>B>C scheme
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
nstrong
Posts: 21
Joined: Thu Apr 02, 2009 11:43 pm

Re: ListBox in Subform

Post by nstrong »

I have rewritten the coding, go through all the properties, and it still does not allow me to access the listbox in the subform. However i can still use the other listboxes in the main form properly.

What do you mean by:
[Source Table] >> [Displayed Field & Bound Field] > [Linked Form Field]?
OOo 2.4.X on Ms Windows XP
nstrong
Posts: 21
Joined: Thu Apr 02, 2009 11:43 pm

Re: SOLVED ListBox in Subform

Post by nstrong »

Never Mind I solved it. I had my table named different from what i was referencing.

Thanks
OOo 2.4.X on Ms Windows XP
Post Reply