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

Passing multiple variables to a query

Greetings.

I have a problem that I have too little experience to solve, so I hope you guys can point me in the right direction:

I have 5 comboboxes with Name, Activity, Product, Project and Customer.
I want to create a report based on a query in which I freely can use 1 or more of the above criterias, i.e:
Just Name, or Name AND Project, or Project AND Product AND Name, or Customer AND Name, or just Customer, or.... well I think you get the scenario.
IS THIS AT ALL POSSIBLE IN JUST ONE QUERY?
or how will I go about to get this report to become real?

Hope you can help me...
Jan 16 '07 #1
4 3779
MMcCarthy
14,534 Expert Mod 8TB
Greetings.

I have a problem that I have too little experience to solve, so I hope you guys can point me in the right direction:

I have 5 comboboxes with Name, Activity, Product, Project and Customer.
I want to create a report based on a query in which I freely can use 1 or more of the above criterias, i.e:
Just Name, or Name AND Project, or Project AND Product AND Name, or Customer AND Name, or just Customer, or.... well I think you get the scenario.
IS THIS AT ALL POSSIBLE IN JUST ONE QUERY?
or how will I go about to get this report to become real?

Hope you can help me...
Each of the combo boxes could have a default '<All>' value which means if you don't select a value it will return all values.

The way to get <All> is something like the following using Customers Table as an example.

Set the combo box row source to ....

Expand|Select|Wrap|Line Numbers
  1. SELECT '*' AS CustID, '<All>' AS CustName
  2. UNION
  3. SELECT CustID, CustName
  4. FROM Customers;
Mary
Jan 16 '07 #2
Each of the combo boxes could have a default '<All>' value which means if you don't select a value it will return all values.

The way to get <All> is something like the following using Customers Table as an example.

Set the combo box row source to ....

Expand|Select|Wrap|Line Numbers
  1. SELECT '*' AS CustID, '<All>' AS CustName
  2. UNION
  3. SELECT CustID, CustName
  4. FROM Customers;
Mary
I've got to be stupid, but I dont understand at all...

I thought that the query should be the issue..
Something like
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM Projectdata WHERE Projectdata.Name  = cboName.Value AND Projectdata.Activity = cboActivity.Value AND Projectdata.Customer = cboCustomer.Value 
and so on...
But that SQL-code assumes that every cbo-box.Value really has a value in it.
If I try this and only choose values from one or more, but not all cbo-boxes then the query results in nothing.

Or am I totally lost? :-/
Jan 16 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
I've got to be stupid, but I dont understand at all...

I thought that the query should be the issue..
Something like
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM Projectdata WHERE Projectdata.Name  = cboName.Value AND Projectdata.Activity = cboActivity.Value AND Projectdata.Customer = cboCustomer.Value 
and so on...
But that SQL-code assumes that every cbo-box.Value really has a value in it.
If I try this and only choose values from one or more, but not all cbo-boxes then the query results in nothing.

Or am I totally lost? :-/
If you use the default value of <All> this will result in the '*' wildcard which will return all values if no other value is selected.

Mary
Jan 16 '07 #4
NeoPa
32,556 Expert Mod 16PB
An alternative would be to structure the WHERE clause of your query for each field so that if the criteria is not specified at all, it will return all items.
An example for a Name field using cboName on the form frmMyForm would be :
Expand|Select|Wrap|Line Numbers
  1. WHERE ((...) AND ([Name] Like Forms!frmMyForm!cboName & '*') AND (...))
Does that make sense?
Jan 16 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Amr Mostafa | last post by:
Hello :) I'm trying to write a script that deals with a web service. I'm using NuSoap class. my question is : Can I pass some variables By Reference to the web service and get the result back...
3
by: bpschmid | last post by:
Ive got a datagrid with a hyperlink column. I want to click on that column and go to another page, but here's the kicker, I need and want to pass not one, but two different query string parameters...
12
by: zig | last post by:
I've posted this on alt.comp.lang.coldfusion, but is predominantly a javascript problem: I have a CF query which returns several rows of records. I wanted to have a checkbox on each record of...
5
by: Jack | last post by:
Hi, I need to pass multple variables in a link in order to go to a asp page with the two varables. The following are the values of the variables using response.write: <%'Response.Write Mypage...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
1
by: Eric | last post by:
Hello, I am trying to come up with the best way to pass large amounts of data from page to page, namely a data table. The user needs to enter data into a form in one page and confirm it on...
1
by: Roy | last post by:
I'm assuming this is amazingly simple and I'm just missing the boat. On the html side of an asp.net page I have a datagrid, a "search" button, and 8 text boxes for search criteria. A user enters...
9
by: laurenq uantrell | last post by:
I've gotten sort of fed up with dealing with regional date settings on the client side and am considering the following scheme - just wondering if anyone has a negative view of it or not: ...
2
by: bcshaw | last post by:
Hey all I have a vb.net/asp.net dynamic website connected to an access database using a oledb connection. I use a datareader to retrieve the results of a query and iterate through the results using...
7
by: DazlerD | last post by:
Hi everyone I am writting an application in VB.NET to print orders. The orders are shown on screen in a listview and the user can select individual orders/range of orders to print. This Access...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...

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.