473,544 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6058
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

dim strName as string
strName = lst2ColumnListB ox.Column(1,lst 2ColumnListBox. ListIndex)

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

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

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

iQA/AwUBQcO6M4echKq OuFEgEQI8sQCdH6 yKgGxfdiXvhN5zL glcGIhjoggAoKyT
FXptOsHrFtJvfHb 4M901AKdW
=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_bytMarketRegi onNewFlag Then
For Each varItem In Me!lstMarketReg ionNew.ItemsSel ected
strMarket = strMarket & Me!lstMarketReg ionNew.ItemData (varItem)
strRegion = strRegion & Me!lstMarketReg ionNew.Column(2 , varItem)
strMarket = strMarket & strCriteria
strRegion = strRegion & strCriteria
Next varItem
'~
MsgBox CStr(Left$(strM arket, Len(strMarket) - Len(strCriteria ))) & vbCrLf &
_
CStr(Left$(strR egion, 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******** *********@newsr ead1.news.pas.e arthlink.net...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

dim strName as string
strName = lst2ColumnListB ox.Column(1,lst 2ColumnListBox. ListIndex)

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

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

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

iQA/AwUBQcO6M4echKq OuFEgEQI8sQCdH6 yKgGxfdiXvhN5zL glcGIhjoggAoKyT
FXptOsHrFtJvfHb 4M901AKdW
=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
3099
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 BoundColumn property is set to 2 At runtime I want to change the BoundColumn property : Dim sOndertekenaar1 As String, sFunctieOndertekenaar1 As String Me!cbxOndertekenaar1.BoundColumn = 1...
3
2347
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, everything works fine, but as soon as I add a BoundColumn, the ItemCommand event doesn't seem to get called. I've been struggling with this for too long now, I'm certain there's something I'm not...
3
1201
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 'No' instead. Or better yet, an image only if the value equals one. Does anyone have some code sample of how this could be done in code-behind? Here's my bound column code: dgc = new...
7
7792
by: Volodymyr Lozovoy | last post by:
Hi All, who suggest why subj do not affect on displayed result for date?
1
1876
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 values and update the db, so that's ok. (btw, it's not as easy as the book claims...) Now I'd like to format some columns, say date values, and what's more, I'd like to make some columns not...
3
2908
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: <asp:BoundColumn DataField="CompanyDesc" HeaderText="Company:" ReadOnly="true" Visible="true" ItemStyle-Width="135px"
1
3734
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 default displays the and that's BAD!!!!! I've tried the following in the ItemDataBound event but it gave me an "invalid cast" error: DataRowView dataRowView = (DataRowView)e.Item.DataItem; for (int...
1
3310
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 TemplateColumns. There's an EditCommandColumn as well. All the columns including the BoundColumn but excluding the EditCommandColumn can be sorted. The column sorted is also accompanied by an image to...
0
1453
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 field value in code behind? If I use BoundField I can't get the value in codebehind if I switch to Template field I can get the value in code with following statment but my sorting is disspeared?
1
2028
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 way to do that? Thanks in advance.
0
7365
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7607
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7709
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5909
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5297
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4918
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3409
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
988
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.