Help with multiple selection list boxes...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an Access 2000 database and on 1 form a listbox that links to a
Countries table.
What I need to do...IN THE SIMPLEST WAY...is to allow multiple countries to
be selected...and when the data entry person comes back to that record...to
see what selections were made from the listbox.

Not sure how multiple selections get saved in the table that will hold these
values...

Having not much experience with listboxes I would need step by step
instructions on...
-what properties need to be set on the listbox to allow multiple selections
-what fields need to be added to the table storing these selections
-what do I need to add to the form in order for the selections to be viewed
on a users return to that record and to make that control searchable by a
selected country.

Thanks!
 
Jacqueline,

I'm afraid you won't like this... the only way to "read" the selections
in a multi-select listbox is through VBA code, and, of course, the only
way to store those selections is, again, through code... this is the
simplest way simply because it's the only one!
Secondly, you can't store multiple selections in a single record;
several countries per whatever-a-record-in-the-form-represents (a person
having visited those countries, for the sake of the argument?). This is
a one-to-many or many-to-many relationship (depends on what you are
modelling) so the way to treat it is by means of a linked table. To use
my travellers example (people visiting countries), you must already have
a table for Travellers (your form's record source) with a TrID primary
key, and a table for Countries with a CtryID primary key; you need a new
table Countries_Visited with fields TrID and CtryID (plus others
possibly, like year visited etc.), and the way to store the information
is, for each traveller to create as many records in Countries_Visited as
the number of countries. So, if John Smith (TrID = 1) has visited Greece
(CtryID = 'GR') and Italy (CtryID = 'IT') and Hellen Jones (TrID = 2)
has visited Germany (CtryID = 'DE'), Canada (CtryID = 'CA') and Greece
then your table Countries_Visited should look something like:

TrID CtryID
1 GR
1 IT
2 DE
2 CA
2 GR

Like I said before, populating the table from the form can only be
accomplished through VBA code.

Need more help?

Nikos
 
I did something similar a while back. It's not exactly simple - too much to
explain in a newsgroup. I can email you my demo .mdb if you'd like to have
a look. Email me at (e-mail address removed)

HTH
Sam
 
Back
Top