need help with select all script. (1 Viewer)

darksniper

Registered User.
Local time
Today, 01:12
Joined
Sep 4, 2005
Messages
108
Hi,

I have an on click event which adds selected items into a string
Code:
Private Sub lstMailTo_Click()
Dim varItem As Variant
Dim strList As String

With Me!lstMailTo
    If .MultiSelect = 0 Then
        Me!txtSelected = .Value
    Else
        For Each varItem In .ItemsSelected
            strList = strList & .Column(0, varItem) & ";"
        Next varItem
        strList = Left$(strList, Len(strList) - 1)
        Me!txtSelected = strList
    End If
End With
End Sub

I also have a code that "select all" items in the list.
Code:
Private Sub btnSelectAll_Click()

    Dim i As Integer
    Dim intListCount As Integer
    
    intListCount = lstMailTo.ListCount - 1
    
    For i = 0 To intListCount
    lstMailTo.Selected(i) = True
    Next

End Sub
When I select items manually, and then output the selected items, I see them. The issue that I am having when I click select all, and return the list of items selected, I get a blank screen.

Is there any way to fix the issue.

Thank you!
 
Last edited:

boblarson

Smeghead
Local time
Today, 01:12
Joined
Jan 12, 2001
Messages
32,059
Don't know if this will help but in your Click event I usually would have replaced this:

strList = strList & .Column(0, varItem) & ";"

with this:

strList = strList & .ItemData(varItem) & ";"
 

darksniper

Registered User.
Local time
Today, 01:12
Joined
Sep 4, 2005
Messages
108
Don't know if this will help but in your Click event I usually would have replaced this:

strList = strList & .Column(0, varItem) & ";"

with this:

strList = strList & .ItemData(varItem) & ";"

The onClick event work, to select items while clicking on them. To be precise I would like to merge the 2 scripts above. In other words, the "select all script" should return a "Me!txtSelected" with all of the items selected.
 

boblarson

Smeghead
Local time
Today, 01:12
Joined
Jan 12, 2001
Messages
32,059
The onClick event work, to select items while clicking on them.
But have you tried my way to see if it actually makes a difference with your select all?

To be precise I would like to merge the 2 scripts above. In other words, the "select all script" should return a "Me!txtSelected" with all of the items selected.
All you have to do is to call the click event after the select all stuff

lstMailTo_Click
 

darksniper

Registered User.
Local time
Today, 01:12
Joined
Sep 4, 2005
Messages
108
But have you tried my way to see if it actually makes a difference with your select all?

All you have to do is to call the click event after the select all stuff

lstMailTo_Click

I have just tryed that, I get an error, "unknown message receipients"
 

boblarson

Smeghead
Local time
Today, 01:12
Joined
Jan 12, 2001
Messages
32,059
well I didn't see anything else - it all seemed to be correct code to me.
 

Users who are viewing this thread

Top Bottom