473,473 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Passing multiple variables to a query

2 New Member
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 3783
MMcCarthy
14,534 Recognized Expert Moderator MVP
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
Hapnadsmannen
2 New Member
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 Recognized Expert Moderator MVP
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 Recognized Expert Moderator MVP
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: 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
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...
1
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...
0
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...
1
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.