Multi Select Names on a Form

I

Implacable

Hi everybody! I am trying to multi select in a list box but i get this error
message:
The field <name> cannot contain a Null value because the Required property
for this field is set to True. Enter a value in this field. (Error 3314)
What I am trying to do is to select names from a table and store them in
another table (employees who took a class on this date). I could only do it
if i select only one, if I enable multi select either simple or extended
that is when i get this message. Is there any macro or code that would let
me do
this task? Thanks!
 
D

Douglas J. Steele

Multiselect list boxes always return Null, regardless of how many records
may be selected in them.

You need to loop through all of the entries in the control's ItemsSelected
collection. Here's an example from the Help file:

Sub BoundData()
Dim frm As Form, ctl As Control
Dim varItm As Variant

Set frm = Forms!Contacts
Set ctl = frm!Names
For Each varItm In ctl.ItemsSelected
Debug.Print ctl.ItemData(varItm)
Next varItm
End Sub
 
I

Implacable

Hello and Thank you for replying!
I don't have experience in programing so can you tell me where exactly i
have to go to change/add this settings?
I have Access 2003. Thanks!
 
D

Douglas J. Steele

Since you don't know in advance how many rows the user is going to select,
it's normal to add a button that the user clicks on when done.

You'd put the code to read what was selected in the Click event for that
button.
 
I

Implacable

Do I copy and paste the code that you gave me? What fields if any i have to
change? Should I use Visual Basic for the code? Thanks!
I am also looking at the "Various ways of using the List Box control" in
your website, hoping to find the answer there as well. Thak You!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top