473,394 Members | 1,742 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,394 software developers and data experts.

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]![frmInterestRptSelect]![whereClause].Value = whereClause

Then in Query1, I have this:

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

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

However, if I replace "[Forms]![frmInterestRptSelect]![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 1923
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.onvoy.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]![frmInterestRptSelect]![whereClause].Value = whereClause

Then in Query1, I have this:

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

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

However, if I replace "[Forms]![frmInterestRptSelect]![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
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...
1
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...
6
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...
9
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...
4
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...
1
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...
2
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...
5
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...
3
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...
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
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
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
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...
0
jinu1996
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...
0
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...

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.