Select all from listbox

David b

Registered User.
Local time
Today, 16:59
Joined
Mar 2, 2003
Messages
102
I have a routine for selecting contacts that works like this. - 2 list boxes side by side. The one on the left contains all records or can be filtered by region.
Double clicking a line stores the paperid in a table by way of the sql INSERT INTO temppaperid ( paperid )
SELECT paperdetails.paperno
FROM paperdetails
WHERE (((paperdetails.paperno)=[Forms]![selectpapers]![List0])); and the name is displayed in the right side listbox.

I would like a button that selects all in the left listbox and pops them into the table.
Any thoughts on the best way to do this ?
TIA
David B
 
You can either use a loop to go through all the entries in the left side listbox, or if the rowsource for the left side listbox is a constant, you can move them all together using a reference to the rowsource.
 
What will the code look like to do that
DB
 
If you want to loop through all items in your listbox, use something like this:

Dim intX As Integer

For intX = 0 To Me.lstbox.ListCount - 1
  'put code here referencing Me.lstTest.ItemData(intX)
Next intX


It can be slow for large rowsources, though. You might want to consider working with the rowsource of the listbox directly and using an update query.
 
Thanks for the reply. Tried the simple way, an append query based on the query that feeds the list box and that seems to work OK
DB
 
Cool. I bet it's faster and it will be simpler to understand when you look at months from now.
 

Users who are viewing this thread

Back
Top Bottom