Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2003 Multi Select List Box

Status
Not open for further replies.

Fixles

Programmer
Jan 24, 2002
36
0
0
GB
Hi,

I've recently designed a contact management system in access 2003 to make my job as a Headhunter easier. I'm very happy with it overall apart from....

I can’t get a List box to populate a text field with multi select. It works when the Multi Select property of the List box control on the form is set to None (Allows me to select one item in the list box and populates the field in the table) but when I set it to Simple or Extended it lets me select but doesn’t populate the table??

A few more details...

Contacts_Table (Truncated)
Contact ID {Primary Key, Auto Number}
Name (Text, Length 50)
Technologies (Text, Length 50, Lookup to Technologies_table.Technologies}

Technologies_Table
Technologies {Primary Key, Text, Length 50)

In sumary all I want to do is select multiple items in a list box and populate the data into a table.

I'm sure it’s something simple I've overlooked but I've been trying and reading for two days and not solved it.

Any help would be much appreciated!

Thanks,

James

 
?
You want to place a list of items, probably separated by a what?, into a single textbox(a single field) of a table?? Why? Or do you mean one record per item?

You have an autonumber as a primary key for your Contacts_Table. Not good practice. Search the Access forums to see why you should not use autonumber in this case.

Do you just want to assign a number of Technologies to a Contact? If you could explain clearer what your goal is, please do. You already have a lookup to Technologies. I get the feeling you want a multi-field primary key on ContactID and Technologies. So you will be able to have:
Joe Programmer
Joe Analyst
JOe Manager

Also, you may want to try the search function to see how to handle multi-select listboxes. You must code for the selections.

 
How are ya Fixles . . .

As a starting point in the [blue]AfterUpdate[/blue] event of the listbox, copy/paste the following:
Code:
[blue]   Dim Lbx As ListBox, Pack As String, idx
   
   Set Lbx = Forms![purple][b][i]YourFormName[/i][/b][/purple]![purple][b][i]ListboxName[/i][/b][/purple]
   
   For Each idx In Lbx.ItemsSelected
      If Pack <> "" Then
         Pack = Pack & ";" & Lbx.Column(1, idx)
      Else
         Pack = Lbx.Column(1, idx)
      End If
   Next
   
   Me![purple][b][i]TextboxName[/i][/b][/purple] = Pack
   
   Set Lbx = Nothing[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top