473,395 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Walk Multi Select List Box A2003

SKG
Hi All

I am using standard code to walk through a multi select list boxes and
build a sql string to filter data, I would also like to store the 2nd
column value for each selected item as well in say strFilter, but seem
to have trouble with the correct syntax / column property

For Each strItem In cntl.ItemsSelected
strSQL = strSQL & cntl.ItemData(strItem) & " Or [staStatusID]= "

Next strItem
Thanks for any help
Steve G

Nov 13 '05 #1
2 1493
SKG wrote:
Hi All

I am using standard code to walk through a multi select list boxes and
build a sql string to filter data, I would also like to store the 2nd
column value for each selected item as well in say strFilter, but seem
to have trouble with the correct syntax / column property

For Each strItem In cntl.ItemsSelected
strSQL = strSQL & cntl.ItemData(strItem) & " Or [staStatusID]= "

Next strItem
Thanks for any help
Steve G


Not sure I follow. This maight help...
Dim var As Variant
Dim strFilter As String
If me.listbox0.ItemsSelected.Count > 0 then
For Each var In Me.ListBox0.ItemsSelected
'get the second column value in listbox
strFilter = strFilter & Me.ListBox0.Column(1,var) & ", "
next var
'remove comma and add ()
strFilter = "Where [staStatusID]IN " & _
(" & left(strFilter,len(strFilter)-2) & ")"
endif

This might end up like
Where [staStatusID]IN (1,2,3,4,5)

Now you can add the filter to the SQL statement.
strSQL = "Select * From Emp " & strFilter & " Order By EmpName
Nov 13 '05 #2
SKG
Hi Salad

Yep Thanks for the ideas, just me not thinking very straight. Amended
to read....
For Each strItem In cntl.ItemsSelected
strSQL = strSQL & cntl.ItemData(strItem) & " Or [staStatusID]= "
strFilter = strFilter & cntl.Column(1, strItem) & ", "
Next strItem
A bit of tidying up at the end to get rid of any unwanted spaces &
commas etc etc and easy as you like....

Thanks again for your help in pointing me in the right direction

Cheers

Steve G

Nov 13 '05 #3

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

Similar topics

2
by: Henry Craven | last post by:
I've inherited my pet hate, which is an ADP. Original developers have coded themselves into a corner with this, and I need to make lots of changes to many dozens of screens. With DAO I could...
2
by: google | last post by:
Hello everyone, I am having an issue using the "Multi Select" option in a list box in MS Access 2003. I am making a form that users can fill out to add an issue to the database. Each issue can...
3
by: syounger | last post by:
Hi. I have a report in Access 2000 that is based on selection made from a series of interdependent list boxes. The boxes I have right now are Source, Table, Column, Date. The user chooses Source...
1
by: Tim Marshall | last post by:
A2003. I am getting this error message when I try to set a report's recordsource to an SQL statement or a saved querydef that uses sub-queries. I've debug.printed the SQL, and run it as a stand...
2
by: Zlatko Matić | last post by:
Hello. How to reference selected values from a multi-select list box, as a criteria in a query ? Is it possible at all? Regards, Zlatko
5
by: dkelly925 | last post by:
Is there a way to add an If Statement to the following code so if data in a field equals "x" it will launch one report and if it equals "y" it would open another report. Anyone know how to modify...
2
by: probashi | last post by:
Hi, Using the SqlDataSource/SelectParameters/ControlParameter one can easily bind a Grid View with a list box (or any other controls), pretty cool, but my list box is multi select. My...
1
by: KrazyKasper | last post by:
Access 2003 – Multi-Column List Box – Select Multiple Items I have a multi-column (3 columns) list box that works well to select one set of records or all sets of records (based on the first field...
11
by: woodey2002 | last post by:
This problem is driving me crazy. Hello there, i am trying to create a search form for records in my access database. The search form will contain text boxes and a multi select list box. The user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

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.