472,325 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,325 software developers and data experts.

How do I...return non BoundColumn value from MultiSelect-Extended listbox using VBA?

Hello world:

I'm using Access 2003. I have 2 listboxes. One is a single column.
The other has two columns. I can use Dev Ashish's code (thanks Dev!) from
the Access MVP Website to accumulate the values from the bound column of a
MultiSelect listbox, so that I can include them in a SQL query that will
then be the recordsource for a report. This gives me 2 of the 3 values I
need to put into the SQL query. However, I can't get the non bound column
value from the 2 column listbox. How do I do this? I know that there must
be a way. Thanks in advance for any help offered.

Alan
Nov 13 '05 #1
2 5978
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

dim strName as string
strName = lst2ColumnListBox.Column(1,lst2ColumnListBox.ListI ndex)

Columns are zero-based therefore column 2 is indicated by .Column(1).
The selected row is indicated by the ListBox's .ListIndex property.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQcO6M4echKqOuFEgEQI8sQCdH6yKgGxfdiXvhN5zLglcGI hjoggAoKyT
FXptOsHrFtJvfHb4M901AKdW
=ETJE
-----END PGP SIGNATURE-----
Alan Lane wrote:
Hello world:

I'm using Access 2003. I have 2 listboxes. One is a single column.
The other has two columns. I can use Dev Ashish's code (thanks Dev!) from
the Access MVP Website to accumulate the values from the bound column of a
MultiSelect listbox, so that I can include them in a SQL query that will
then be the recordsource for a report. This gives me 2 of the 3 values I
need to put into the SQL query. However, I can't get the non bound column
value from the 2 column listbox. How do I do this? I know that there must
be a way. Thanks in advance for any help offered.


Nov 13 '05 #2
Hi MG:

Many thanks! Your basic idea worked great! I had to tweak it a little
bit for my particular case. Here's what my successful code looks like:

Dim varItem As Variant
Dim strMarket As String
Dim strRegion As String
Dim strCriteria As String

strMarket = ""
strRegion = ""
strCriteria = ","

'--Load selections from MarketRegionNew listbox into variables
If m_bytMarketRegionNewFlag Then
For Each varItem In Me!lstMarketRegionNew.ItemsSelected
strMarket = strMarket & Me!lstMarketRegionNew.ItemData(varItem)
strRegion = strRegion & Me!lstMarketRegionNew.Column(2, varItem)
strMarket = strMarket & strCriteria
strRegion = strRegion & strCriteria
Next varItem
'~
MsgBox CStr(Left$(strMarket, Len(strMarket) - Len(strCriteria))) & vbCrLf &
_
CStr(Left$(strRegion, Len(strRegion) - Len(strCriteria)))
End If

My listbox actually has 3 columns -- AirportCode (hidden, boundcolumn),
MarketName, and RegionNameNew. When I run this routine and get the
MessageBox, it shows me the correct list of selected Markets and then
Regions from the listbox. Yay!

Alan

"MGFoster" <me@privacy.com> wrote in message
news:5U*****************@newsread1.news.pas.earthl ink.net...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

dim strName as string
strName = lst2ColumnListBox.Column(1,lst2ColumnListBox.ListI ndex)

Columns are zero-based therefore column 2 is indicated by .Column(1).
The selected row is indicated by the ListBox's .ListIndex property.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQcO6M4echKqOuFEgEQI8sQCdH6yKgGxfdiXvhN5zLglcGI hjoggAoKyT
FXptOsHrFtJvfHb4M901AKdW
=ETJE
-----END PGP SIGNATURE-----
Alan Lane wrote:
Hello world:

I'm using Access 2003. I have 2 listboxes. One is a single column.
The other has two columns. I can use Dev Ashish's code (thanks Dev!)
from the Access MVP Website to accumulate the values from the bound
column of a MultiSelect listbox, so that I can include them in a SQL
query that will then be the recordsource for a report. This gives me 2
of the 3 values I need to put into the SQL query. However, I can't get
the non bound column value from the 2 column listbox. How do I do this?
I know that there must be a way. Thanks in advance for any help offered.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ronny Sigo | last post by:
Hello all, On my form I have an unbound combobox with with 3 columns. It gets its values from a query. On the property sheet of the combobox its...
3
by: John | last post by:
The ItemCommand event not getting fired when I add both a BoundColumn and a ButtonColumn to a datagrid. When I add a ButtonColumn by itself,...
3
by: Andrea Williams | last post by:
I have a BoundColumn which shows a field called 'IsPrimary'. Straight from the database, the field is a 1 or 0 (bit). But I want to show 'Yes' or...
7
by: Volodymyr Lozovoy | last post by:
Hi All, who suggest why subj do not affect on displayed result for date?
1
by: niki | last post by:
Hello. I have a problem with custom columns inside the datagrid. I've set up a datagrid that populates from a database; I can edit the datagrid...
3
by: tshad | last post by:
In a datagrid, is there a way to put a tooltip and use a field from the data that is returned from the sql statement to fill it? For example: ...
1
by: Calvin KD | last post by:
Hi everyone, Can someone show me how to display an empty string in a boundcolumn of a datagrid when the data source item is NULL. Datagrid by...
1
by: rn5a | last post by:
A DataGrid has a BoundColumn which changes to a TextBox when the DataGrid is in the editable mode. The rest of the columns in the DataGrid are...
0
by: mesut | last post by:
Hi colleagues, I'm confused when to use Boundcolumn and when to use TemplateField in ASPX pages. If I use BoundField control how can I get the...
1
by: Jen | last post by:
I have a BoundColumn that displays a numeric value. I want to override the number if it is zero and display a string instead. What's the easiest...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.