Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2008
    Posts
    13

    Unanswered: Listbox with multichoice

    In my DB a have main table which contains record data.

    In the table there is field with month name - and can be only one month name or several for one record

    I created another table with:
    MonthID, month, MonthNO
    1 , january, 1
    2, february, 2
    3, march, 3 and so on.

    In form I made a listbox with multiselect - and when inputting data I can select several months, but when I go to see the main table, the field are not populated - I only have dropdown option with all months listed top select.

    whats wrong with it?

  2. #2
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    994
    Provided Answers: 2
    You're trying to store multiple values in one field. This is a major no-no of database design.
    What you need is an intersection table that links the record in you main table with as many months as required from the months table.

  3. #3
    Join Date
    Oct 2003
    Posts
    103
    Quote Originally Posted by weejas
    You're trying to store multiple values in one field. This is a major no-no of database design.
    What you need is an intersection table that links the record in you main table with as many months as required from the months table.
    I am interested in this, as I've gone back and forth on this issue. Can you expand on that or point to a resource/book etc where we can look further?

  4. #4
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    994
    Provided Answers: 2
    The easiest way to illustrate the point is with a library database. In it, you have a table of authors and a table of books. One book can have multiple authors, and most authors write more than one book. The way to join them is with an intersection table. This is composed of just two columns (or as many as the number of tables you're joining together), with both of them forming the primary key. http://www.htmlforums.com/databasing...e--105965.html is another example.
    In your case, the columns in the intersection table columns would be MonthID and MainID (or whatever that field is). Whenever an item in the list box is selected or deselected, you'd need some code to add or remove a record to or from the intersection table that consisted of the ID of the Main record, and the ID of the month that had just been selected or deselected. (I'd have a go at mocking something up, but I've just spent 150 minutes to travel four miles >.<)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •