Multiple Selection in List Box.

C

cel504

I have been reading the threads relating to this item and I think I have lost
the plot somewhere. If I wish to use this functionality in a listbox, will I
have to write a code to do it? If so, where do you write the code, in the
event of the listbox, or in the event of button which then runs the query
after the multiple selection is made. Also, could someone just explain the
meanings of the code, that needs to be written.

Any help on this would be gratefully apprecated. I have had a real good go
at trying to solve it myself, but need more support.

Cel504.
 
R

Roger Carlson

You don't need to write code to make it multi-select capable, you just need
to set the property. But you *do* need to use code to do anything with the
selections. Exactly what that code is depends on what you want to do with
it.

On my website (www.rogersaccesslibrary.com), I have severall small Access
databases which illustrate different ways to use multi-select listboxes.

You can find them here:
http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=368
http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=323
http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=315

Look in the code behind the forms to see the code.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
C

CEL504

Roger, thanks very much for the quick response. However, to answer your
question, I wish to be able to do a multiple selection from a list, then run
a query on the items selected in the list. I understand that a code would
have to be written inorder to do this, and I have seen samples of the code.
But, at a base level and what is confusing me, is where do I write the code.
Is it in the properties of the Listbox, or in the properties of the button
which then runs the query. I know this may apprear basic, but to me, one of
the hurdles you need to get over so that you can advance.

Thanks for you help and advice to date.

Cel504.
 
R

Roger Carlson

Well, that's why I suggested you download some of my samples. Then you can
see exactly where I put the code and what it looks like.

But in answer to your question, there is no single correct place to put the
code. In the CreateQueries2.mdb sample (which is closest to what you want
to do), I put the code in the OnClick event of the button. However, the
code could be in a subroutine (of the form OR of a general module) and
simply be called from button or some other event procedure.


--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
C

CEL504

Roger, as ever thanks for the advice and I have looked at your samples and I
think they are excellent. I have read a lot of the threads too and tried to
enter the code people have suggested and to date it hasn't worked. The code I
have enter appears correct, yet when I select more than one with the listbox
property set to say simple, the query is blank. When I set the property to
none, it does select that record.

I have no doubt you are extremely busy, but thanks for all you help to date.
 

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