473,698 Members | 2,398 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ItemsSelec ted
strSQL = strSQL & cntl.ItemData(s trItem) & " Or [staStatusID]= "

Next strItem
Thanks for any help
Steve G

Nov 13 '05 #1
2 1504
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.ItemsSelec ted
strSQL = strSQL & cntl.ItemData(s trItem) & " 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.Ite msSelected.Coun t > 0 then
For Each var In Me.ListBox0.Ite msSelected
'get the second column value in listbox
strFilter = strFilter & Me.ListBox0.Col umn(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.ItemsSelec ted
strSQL = strSQL & cntl.ItemData(s trItem) & " 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
1616
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 walk the collections and make changes to the properties of the forms from code. I can't for the life of me get this to work in a dap. Other than getting a list of the form Names, I get nothing. I can't even get a list of the form properties much...
2
3034
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 be associated with multiple categories. I have an "Issue," "IssueCategory," and "Category" in the database (among other tables). The form has a subform in it which is tied to the "IssueCategory" table. The main form is tied to the "Issue"...
3
2884
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 first, then the Table list box populates only tables from that source. Once a table is chosen, only the columns for that table appear in the Column list box. In the date box, the only dates that appear are those that are stored against the...
1
7195
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 alone query, as a rowsource for a list box and as a recordsource for a form. There's no problem. I'm only encountering this in reports. As a stop gap, I'm going to use a form for a printe report, bvut I wonder if anyone has encountered...
2
14743
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
3280
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 this? Private Sub cmdPreview_Click() On Error GoTo Err_Handler 'Purpose: Open the report filtered to the items selected in the list box. 'Author: Allen J Browne, 2004. http://allenbrowne.com Dim varItem As Variant 'Selected items
2
4081
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 questions is, how can I bind a Grid View Control to a multi select list box (or any multi values controls) Thanks
1
4881
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 in the list box). I need to it also select multiple sets of records (Multi-Select = Extended). I modified my code based on code I found on some Internet site which gave an example using three fields in a three field table. It loops through the...
11
5598
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 can enter their search criteria eg. surname, reg num, etc. in the text boxes. The multi select list box allows the user to select multiple counties which they have the option of including in the search. The user should be able to select or omit the...
0
8678
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9166
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7737
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.