By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,291 Members | 1,613 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,291 IT Pros & Developers. It's quick & easy.

Multi-select list box

P: n/a
yb
I have a unbound mult-select listbox field named
"Locations".Multi-select option is set to "Extended". I'm having
problem saving the values from this field into table. I have text
column currLocations in the table in which I want to store the selected
values.

I do not want to go with the approach of creating another hidden
textbox on the form and write code in AfterUpdate of the listbox field
to populate the selected values into the text field.

I have read about using subforms but do not know how to exactly do
it.please help!!

Thanks
YB

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
This example assumes that for each client you want to store their favorite
colors.

You need these 3 tables:
Client table, with fields:
ClientID AutoNumber primary key
Surname Text
FirstName Text
...

Color table:
ColorID Text the color name.

ClientColor table:
ClientID Number relates to Client.ClientID
ColorID Text relates to Color.ColorID

Now on your Client form, place a subform bound to the ClientColor table. The
subform will show the client's fave colors, one per row. In the subform,
place a combo box you can select a color. The RowSource of the combo is the
Color table.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"yb" <ya**********@hotmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
I have a unbound mult-select listbox field named
"Locations".Multi-select option is set to "Extended". I'm having
problem saving the values from this field into table. I have text
column currLocations in the table in which I want to store the selected
values.

I do not want to go with the approach of creating another hidden
textbox on the form and write code in AfterUpdate of the listbox field
to populate the selected values into the text field.

I have read about using subforms but do not know how to exactly do
it.please help!!

Thanks
YB

Nov 13 '05 #2

P: n/a
yb
I'm totally lost. Here is what I have:
Table Location:
Location_Id Text

Table Authorized_To_Work
Employee Name Text
Locations Text

form: lblLocations
Field: Location bound to Location.Location_Id and is set to Combobox

form: WorkAuthorization
I have inserted lblLocations but cannot get it to allow multiple
selections.

Please help!!
YB

Nov 13 '05 #3

P: n/a
The issue is that one employee can work an many different locations over
time, and one location can have many many people work there over time. There
is therefore a many-to-many relationship betwen employees and locations.

You already have a Location table and an Employee table. You need a 3rd
table to record who is authorized to work where when:

Location table
Location_ID (primary key)

Employee table
Employee_ID (primary key)
Surname
...

Authorized_To_Work table:
Location_ID relates to a record in Location.Location_ID
Employee_ID relates to a record in Employee.Employee_ID
WordDate when this person is to work here.

Now you will have a main form bound to the Employee table.
It will have a subform bound to the Authozed_To_Work table.
The subform will have a combo where you can select the location for the
employee.

With the same tables, you could interface this by location instead of by
employee if you wish:
- Main form bound to Location table;
- subform bound to Authorized_To_Work table.
The suborm will have a combo where you can select the employee for the
location.

It's really important to grasp this concept: the 3rd table (called a
junction table) resolves the many-to-many relationship into a pair of
one-to-many relationships.

For another example, see:
http://members.iinet.net.au/~allenbrowne/casu-06.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"yb" <ya**********@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I'm totally lost. Here is what I have:
Table Location:
Location_Id Text

Table Authorized_To_Work
Employee Name Text
Locations Text

form: lblLocations
Field: Location bound to Location.Location_Id and is set to Combobox

form: WorkAuthorization
I have inserted lblLocations but cannot get it to allow multiple
selections.

Please help!!
YB

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.