Accessing data in the unbound column of a listbox

User avatar
silverback
5StarLounger
Posts: 771
Joined: 29 Jan 2010, 13:30

Accessing data in the unbound column of a listbox

Post by silverback »

I have a form which displays volunteers' names and their associated email address in a multi select list box. The bound column is the email address. It is used to select multiple email addresses which, when a command button is clicked, are concatenated together to form a bcc list for DoCmd.SendObject VBA command.
This is all working well.
The users would now like to include the volunteers' names in the email text.
Since ItemData returns only the contents of the bound column, how can I obtain the volunteer's name which is displayed in the other column, please?
Thanks
Silverback

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Accessing data in the unbound column of a listbox

Post by HansV »

Hi Silverback,

Welcome to Eileen's Lounge!

Let's say that your listbox is named lstVolunteers and that you have a loop

For Each itm In Me.lstVolunteers.ItemsSelected
...
Next itm

to loop through the selected items. Within the loop, you can refer to a specific column in the list box like this:

Me.lstVolunteers.Column(1, itm)

Columns start counting at 0, so the first column is 0, the second column is 1 etc.
Best wishes,
Hans

User avatar
silverback
5StarLounger
Posts: 771
Joined: 29 Jan 2010, 13:30

Re: Accessing data in the unbound column of a listbox

Post by silverback »

Thanks, Hans.
All working OK
Silverback