473,832 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

listboxes and query conditions

Firstly, I want to thank all that have helped me out with getting grips
on Access each time I've had questions. This has got to be one of the
most helpful groups that I've posted to over the years.

Now my problem...

I have a listbox that I want to use to fill in the where clause of a
query. I've been able to create a string holding the necessary WHERE
clause without many problems. However, I cannot seem to reference the
string inside the query to make it work in Access 2002.

Once the string is built, I set the string to a text box value (which
will be set not to display once I get this figured out):

[Forms]![frmInterestRptS elect]![whereClause].Value = whereClause

Then in Query1, I have this:

SELECT interests.id, interests.name FROM interests WHERE
([Forms]![frmInterestRptS elect]![whereClause])

It pulls up all records as if
[Forms]![frmInterestRptS elect]![whereClause] = "1" or "WHERE" was
removed from the query.

However, if I replace "[Forms]![frmInterestRptS elect]![whereClause]"
with the contents of the text box, the query acts as expected.

I've found some references to using these types of queries by creating
the entire query then setting it as a report recordsource, but what I
need is for this query to be referenced by another query.

What am I missing here, I'm almost convinced it has got to be something
fairly simple...

TIA

--
Justin Koivisto - sp**@koivi.com
http://www.koivi.com
Nov 13 '05 #1
2 1945
Is your listbox multiselect? You can only use the syntax you're showing if
it isn't.

If it is multiselect, take a look at
http://www.mvps.org/access/reports/rpt0005.htm at "The Access Web"

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Justin Koivisto" <sp**@koivi.com > wrote in message
news:_l******** *******@news7.o nvoy.net...
Firstly, I want to thank all that have helped me out with getting grips
on Access each time I've had questions. This has got to be one of the
most helpful groups that I've posted to over the years.

Now my problem...

I have a listbox that I want to use to fill in the where clause of a
query. I've been able to create a string holding the necessary WHERE
clause without many problems. However, I cannot seem to reference the
string inside the query to make it work in Access 2002.

Once the string is built, I set the string to a text box value (which
will be set not to display once I get this figured out):

[Forms]![frmInterestRptS elect]![whereClause].Value = whereClause

Then in Query1, I have this:

SELECT interests.id, interests.name FROM interests WHERE
([Forms]![frmInterestRptS elect]![whereClause])

It pulls up all records as if
[Forms]![frmInterestRptS elect]![whereClause] = "1" or "WHERE" was
removed from the query.

However, if I replace "[Forms]![frmInterestRptS elect]![whereClause]"
with the contents of the text box, the query acts as expected.

I've found some references to using these types of queries by creating
the entire query then setting it as a report recordsource, but what I
need is for this query to be referenced by another query.

What am I missing here, I'm almost convinced it has got to be something
fairly simple...

TIA

--
Justin Koivisto - sp**@koivi.com
http://www.koivi.com

Nov 13 '05 #2
Douglas J. Steele wrote:
Is your listbox multiselect? You can only use the syntax you're showing if
it isn't.

If it is multiselect, take a look at
http://www.mvps.org/access/reports/rpt0005.htm at "The Access Web"


Thanks, but I am using ADO... However, I was able to re-arrange the
queries in a way where I could use a WhereCondition when opening a
report instead of trying to use a query to do so...

--
Justin Koivisto - sp**@koivi.com
http://www.koivi.com
Nov 13 '05 #3

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

Similar topics

1
1731
by: ben | last post by:
I have been using a nasty combination of php and mysql to generate a narrow down by attribute bar as seen on the likes of shopping.com. For example a user could select 4X Zoom to narrow down a selection of digital cameras. The current method I use is to loop though each one of the attributes and their values and run a separate query of each attribute value: for($i=0; $i < attribute_count; $i++) {
1
3458
by: Ryan Govostes | last post by:
Eh, I was wondering if anyone could help me with a SQL query problem I'm having. I'm a complete newbie to SQL and MySQL, so any help would be greatly appreciated. I am using PHP to allow users to submit ISBNs, prices, and item conditions into a MySQL database. The table the values are inserted into is declared with CREATE TABLE prices (isbn VARCHAR(10), price FLOAT UNSIGNED, conditions VARCHAR(5))
6
4636
by: Ralph2 | last post by:
Some time ago with a lot of help from this group I made a reasonably successful database to keep track of our shop drawings. However the searching mechanism is too complicated for the occasional user and I would like to change the whole process. I would like to duplicate the layout of my form... but each field becomes a simple "searching" ListBox. On completing any one search field all the rest are filtered to this value. Subsequent...
9
4957
by: Susan Bricker | last post by:
Hi. I have two questions ... (1) I want to use a Listbox to enable the user to select 1 or many items from the list. However, I'm having trouble figuring out how to find out t which items have been selected. How can I do that? Given the listindex, .selected, .itemsselected, .itemdata properties -- I'm getting confused. (2) I, actually, have two listboxes on the form and I want to ONLY let the user select items in one list. The...
4
1918
by: bill yeager | last post by:
I have several template columns inside of a datagrid. Inside of these template columns are databound listboxes: <asp:TemplateColumn HeaderText="Crew Chiefs"> <ItemTemplate> <asp:listbox AutoPostBack="False" BackColor="#ffffff" id="lstCrewChief" runat="server" Rows="1" DataSource="<%# DsCrewChief1 %>" Enabled="True"
1
1353
by: Ryan Ternier | last post by:
I have two listboxes, and allow users to move items between them via the following function: function SwitchList(fbox, tbox){ var arrFbox = new Array(); var arrTbox = new Array(); var arrLookup = new Array(); var i; for (i = 0; i < tbox.options.length; i++) {
2
4355
by: salad | last post by:
This is a tip on how to speed up listboxes DRAMATICALLY. Persons that would benefit are those that are constantly updating the rowsource of a listbox/combobox in order to filter and sort the data and the refreshes are slow. (OT. I've often wondered why there is no .Sort or .Filter property for Combos and Listboxes.) My listboxes , and their rowsources, on my form were constantly being refreshed to filter and sort data. Ex:
5
2090
by: Samik2003 | last post by:
Hello, The problem is my query is not extracting the correct xml data from the database : Is there something which I am missing?? ANy help would be appriciated. Thanks, Sam. THis is the query which I am using to extract :
3
5055
JodiPhillips
by: JodiPhillips | last post by:
Hello everyone, there are many questions and answers relating to moving items between two listboxes here and on the net in general, however, none answer my specific problem. I have two listboxes on a form. The first listbox is populated according to command buttons (Command 14 & Command 15) that are clicked by the user (draws data via SQL statement - see code below). The second listbox is populated by user selection from the first listbox. I...
0
9795
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
9642
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,...
0
10212
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9319
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...
0
6951
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
5623
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...
1
4421
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
3970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3077
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.