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 2 1505
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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"...
|
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...
|
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...
|
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
| |
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
|
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
|
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...
|
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...
|
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...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |