List question

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

Guest

I created a list box with the multi-select set to simple. How do I get my
list box to store the values selected in the database?
 
Use a subform instead of a mutli-select list box.

If there are many choices applicable to the main record, you *really* need a
related table (one to many relation) to store the many choices for the one
record. Once you have that, it is very easy to create a subform in
continuous view so you can enter as many lines as you need in the subform
for the entries that apply to the record in the main form. No code needed.

If you do have a related table to store the records in, but you want to use
the multi-select list box, you will need to write a considerable amount of
code to correctly populate the list box in the Current event of your form,
restore it in the Undo event of the form, dirty the record in the Click
event of the list box (so that the changes will get written), and
programmatically loop through the ItemsSelected collection of the list box
in the AfterUpdate event of the form to execute a delete query for any item
that is no longer selected, and an append query for any item that is now
selected by was not previously.

That's not trivial code, so use the code-free subform approach if you are
not sure about how to do that.
 
Hi Allen, I'm not sure what you mean. So, you're saying I create a new table
to store the values selected but how do I make the form look similar? Right
now it's a list of values that the user can select 1+.
 
Back
Top