Using MultiSelect Listbox (1 Viewer)

bogglebeats

Registered User.
Local time
Today, 15:30
Joined
Dec 19, 2002
Messages
53
Hello. I am having trouble using a multiselect textbox. Initially, i was using a regular combo box to capture information for clients. In the combobox, only 1 value could be selected from the list. I currently have 40 clients that have only one value recorded for the 'business type' field.

Now i have changed the combobox to a listbox and selected 'extended' value for the multiselect property.

1) when i select 1 or multiple values for any records, no values get saved to the tables. values only get recorded when 'none' is selected for the multiselect value for the listbox.

2) for the previous 40 records that have existed, i cannot see any values selected for the records in the forms, but they are recorded in the tables. how would i get them to display in the forms?

is there any code that needs to be implemented to organzine the data or specify any kind of itemsSelected collection? Please let me know what i need to do to use a multiselect listbox. thanks

ameen
 

dcx693

Registered User.
Local time
Today, 10:30
Joined
Apr 30, 2003
Messages
3,265
bogglebeats, as you perhaps suspected, a multiselect listbox is almost a totally different animal than a "normal" single-select listbox.

To explain and answer your questions:

(1) First, they can be set to be bound controls, but they won't store anything relevant in the source table. A listbox with it's multiselect property set to simple or extended has no value and therefore is equal to Null, that means nothing gets stored in the field. To properly store anything in your table, you'll probably need to change your table structure. And you're right about having to reference the .ItemsSelected property of the listbox to get at the items you've selected. Check out this post for more info and code examples: Multi Select List Box --> Query

(2) if this is a bound field, then it's simple if the listbox is single-select. If it's multiselect, it's a bit tougher, but not crazy. Use a query that pulls the results you want, and use it as the rowsource for the listbox.

By the way, a "bound" control on a form is one that has as it's controlsource a field from the form's underlying table or query.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 10:30
Joined
Feb 19, 2002
Messages
43,603
A little more advice. If a client may have more than one business type then client and business type have a many-to-many relationship. This relationship is properly implemented by creating a separate table to hold the relationship data:

tblClientBusinessType
ClientID
BusinessTypeID

With that structure, a client may engage in any number of businesses and you'll be able to query them and create stats as necessary.

Your current approach seems to be geared toward storing multiple businessType codes in a single field. That is not possible without code and it is not supported in relational databases. Unless you're a glutton for work, don't do it. Use the proper table schema and use a subform to enter the BusinessTypes. Here's an example of a many-to-many db that might help you:

Many-to-Many
 

Users who are viewing this thread

Top Bottom