Page 1 of 1
[Solved] ListBox in Subform
Posted: Wed Apr 22, 2009 9:21 pm
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.
Re: ListBox in Subform
Posted: Wed Apr 22, 2009 9:48 pm
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"
Re: ListBox in Subform
Posted: Wed Apr 22, 2009 10:25 pm
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?
Re: ListBox in Subform
Posted: Wed Apr 22, 2009 10:44 pm
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.
Re: ListBox in Subform
Posted: Thu Apr 23, 2009 9:02 pm
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]?
Re: SOLVED ListBox in Subform
Posted: Thu Apr 23, 2009 10:05 pm
by nstrong
Never Mind I solved it. I had my table named different from what i was referencing.
Thanks