Listbox questions

G

Guest

Hi all

I have used Access for some time but am new to listboxes always having used
a combo box before. I now have a need for multi-selections though hence the
listbox.

What I would like to achieve is

a) to have two listboxes and the 2nd to have the selected choices shown from
listbox1 (basically like the wizard does when you add and remove selections)
I thought I had seen an example somewhere of the two listbox combinations
but I can't find it now. Is this possible?

b) append new records to the form using all the people in listbox2. With the
single selection combo box I have currently I use .addnew but I am not sure
how to incorporate all the selections from a listbox with this.

c) I then filter the form to show the new additions. I use a form filter to
do this querying records between two dates and including the specialist.
Again, I am not sure how to do this with the multi selection.

Any help would be greatly received thanks :).

Sue
 
G

Guest

Thanks Roger

I will have a look at these. I have progressed things slightly - I now have
my two listboxes and a button to add selections to the 2nd list but it only
creates the last name added and not all selections

Code:

Private Sub AddtoList_Click()
On Error GoTo Err_AddtoList_Click

Dim strList As String, varItem As Variant

For Each varItem In List1.ItemsSelected
strList = strList & List1.Column(0) & ","
Next varItem

strList = Left(strList, Len(strList) - 1)

Me.List2.RowSource = "SELECT SpecialistID,Specialist FROM Specialists WHERE
SpecialistID IN (" & strList & ")"

Exit_AddtoList_Click:
Exit Sub

Err_AddtoList_Click:
MsgBox Err.Description
Resume Exit_AddtoList_Click

End Sub
 

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