Limit Value List Records Added To 2nd List Box

L

laknight

Hello, I have a 1st List Box which contains a SELECT DISTINCT source from a
Query. I have the list box set to Simple Select. After the user selects a
record in the list, they hit the command button called SAVE and it moves the
selection into a 2nd list box which when the OK button is clicked are then
used as a filter on a report.

Question 1: How can I limit the number of records SAVED or ADDED to the 2nd
list box. I only want users to pass up to 5 records to the report for
filtering.

Question 2: Is there a way to automatically pass ALL the values in the 2nd
list box without selecting/clicking to highlight them all again and then
click on the OK button. The part of the OK button which contains the code
about selected items is

For Each varItem In .ItemsSelected

Can I do something like For Each varItem In .ItemsSelected.All ?

Using Win XP, Access 2003

Thanks a bunch!
 
L

laknight

There is no "source" to the 2nd list box. The items in the 2nd list box are
"Added" using the AddItem command. This is the code for the SAVE button which
moves list selections one at a time into the 2nd list box.

Private Sub cmdSave_Click()
If (Me.SelectSOListbx.Value = "") Then
DoCmd.OpenForm Form_Error_Range.Name, , , , , acDialog
Else
'Me.SO_List.AddItem Me.SelectSOListbx.Value, index

Call AddItemAction(Me.ORDER_NO, Me.SelectSOListbx.Value)

theSalesOrders = theSalesOrders & Me.ORDER_NO.ItemData(index) & ","
index = index + 1
Me.SelectSOListbx.SetFocus
End If

End Sub
 
D

Dennis

Dim x As Integer

Set frm = Me
Set ctl = frm!MyListBox

For x = 0 To ctl.ListCount - 1
If ctl.Selected(x) = False Then ctl.Selected(x) = True
Next x
 

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