473,659 Members | 2,886 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Define multiple search criteria from one form but only use selected

2 New Member
Hi
I have written a form that has 4 drop down selection boxes on it, with check boxes next to them. When a user selects something from the drop down box the check box is automatically selected. I want to perfom a query and based on what has been selected from the drop down boxes use this information as the criteria. If a user has only selected a supplier name then the query should return all products from that supplier, but if a user selects a supplier name and colour then only products from that supplier that are that colour should be returned. (if that makes any sense?) I can get the query to do what I want on an individual criteria basis, but it is the ability to test whether a check box has been ticked and then apply that criteria that is causing me a headache. Any help on this would be grately appreciated.
Nov 9 '09 #1
2 2575
MMcCarthy
14,534 Recognized Expert Moderator MVP
I don't think you will be able to do this with just a query. I would use a VBA routine to build the query into a string. Something like ....

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim strSQL as String
  3. Dim start as Boolean
  4.  
  5.     strSQL = "SELECT * FROM MyQuery "
  6.     start = False
  7.  
  8.     If Me.Checkbox1 = True Then
  9.         strSQL = "WHERE Supplier='" & Me.combobox1
  10.         start = True
  11.     End If
  12.  
  13.      If Me.Checkbox2 = True Then
  14.         If start = True Then
  15.             strSQL = "AND City='" & Me.combobox2
  16.         Else    
  17.             strSQL = "WHERE City='" & Me.combobox2
  18.             start = True
  19.         End If
  20.     End If   
  21.  
  22.     DoCmd,RunSQL strSQL
  23.  
  24.  
This is just a rough idea to get you started. How you implement the query will depend on your requirements.

Mary
Nov 9 '09 #2
Ru55ell
2 New Member
Thanks for that I've been away for a few days but will give it a go.
Nov 11 '09 #3

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

Similar topics

2
1564
by: Vishy | last post by:
Hi One of the less documented features of xpath is how to run multiple search on nodes or attributes e.g <Book name="Harry Potter" price="10GBP"/> <Book name="Harry Potter" price="5USD"/> now if you want one of them following is xpath query ..//Book
1
8767
by: TH | last post by:
I am (still :) working on a recipe database. Now I am trying to figure out how to set it up for an ingredient search. What I want it to be able to do is three things: 1. Search based on just one ingredient 2 Search based on two ingredients so that the recipe would have to have both ingredients to show up in the results 3. Search based on three ingredients so that the recipe would have to have all three ingredients to show up...
1
8162
by: Casey | last post by:
Hi, How would one allow for possible multiple search criteria using FREETEXTTABLE. For example, my table "listings" has a full-text search catalog, and I may want to: SELECT * FROM listings WHERE name LIKE @name AND city LIKE @city I've got it working to select only by name: SELECT listing_id, RANK, name, address, city, zip, heading, phone FROM listings a,
1
2987
by: pramodrepaka | last post by:
I am using Vb6. I am using data report in my program I have it working but when I print it is printing all the records in the database. I am having troubles with it printing a single record. with the help of dataenvironment. If there is anyone out there that has had this same problem and know how to correct it. I would really appreciate it thank you for your time
3
2441
by: AishaKhalfan | last post by:
Hi, :wave: I have many search criteria in my program, such as: search by name, search by age, search by gender, search by city the user can search by name only, or by name and age, or by name and gender or by city and gender ... etc .. how am going to display the result for each search criteria ?
11
4953
by: Panlflzs | last post by:
Howdy, I am working on a system where I need a basic HTML form to pass data to a cfm page. The cfm page will then query a database and return any matching data. I am using MySQL. I have my HTML page with a form element that allows a user to enter search criteria. When they click submit it sends the data in the text field to a coldfusion page that runs that data through a query to the database. If a match is found it should display the...
5
2205
by: LC2007 | last post by:
Hello, Can someone please help me on how to create Search Criteria form, i can't find exactly what i am looking for!!! i need a search button! but i can't find anything that can help me!
8
6015
by: salzan | last post by:
I have this code: strAny = " = " & rsTemp!YearId rsPerm.Find strAny and it works. However, when I do the following it doesn't strAny = " = " & rsTemp!YearId & " AND " & _ " = " & rsTemp!DeptId & " AND " & _ " = '" & rsTemp!CatId & "'"
11
5593
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...
0
8427
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
8746
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 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...
0
8627
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
7356
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...
1
6179
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
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
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
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.