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

Query by form with different textbox criteria

Hi

i had a form (form2) with a listbox that displays the numbers from 1-12(representing the number of month) and a txtbox on which the user enters the year.

now i want to run a query with the criteria taken from this form ,that displays all the orders in the case of both listbox and txtbox are blank. in case that the user fills only the listbox(months)display all the orders that were made in that month at every year and finally in the case that he only fills the textbox(year) display all of the orders of that year

so far i have managed to make it work with the listbox (month)selected and both (listbox and textbox) blank but with regards to the textbox(year) i hasn't be able to make it work

any help will be appreciated

for more details i leave here the sql code an a picture of how it looks the query

thank you

Expand|Select|Wrap|Line Numbers
  1.  SELECT orders.[or-id], Sum([quantity_x_price_qry(help)].subtotal) AS SumOfsubtotal, orders.DateEntered, Month([orders]![DateEntered]) AS jodesh, Year([orders]![DateEntered]) AS shana, customers.FirstName, customers.LastName
  2. FROM customers INNER JOIN ([quantity_x_price_qry(help)] INNER JOIN orders ON [quantity_x_price_qry(help)].[or-id] = orders.[or-id]) ON customers.[cust-id] = orders.[cust-id]
  3. GROUP BY orders.[or-id], orders.DateEntered, Month([orders]![DateEntered]), Year([orders]![DateEntered]), customers.FirstName, customers.LastName
  4. HAVING (((Month([orders]![DateEntered]))=[Forms]![Form2]![Monthtxt] Or [Forms]![Form2]![Monthtxt] Is Null) AND ((Year([orders]![DateEntered]))=[Forms]![Form2]![YearTxt] Or [Forms]![Form2]![YearTxt] Is Null));
  5.  

Attached Images
File Type: jpg QueryByForm.jpg (26.1 KB, 621 views)
Jul 9 '14 #1
1 1845
zmbd
5,501 Expert Mod 4TB
See if one of these will point you in the right direction...
Don't worry if you don't understand the code, we'll help you thru it, just let us know where you get stuck:
-filtering-
Aug 4 '14 #2

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

Similar topics

3
by: Mike Cocker | last post by:
Hello, I'm quite weak at PHP, so I was hoping to get some help understanding the below code. First off, I'm trying to create a "query form" that will allow me to display the results on my...
3
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
20
by: xixi | last post by:
hi, we use db2 udb v8.1 on windows, i am trying to use federated database objects to create wrapper, even though i have update dbm cfg using federated yes, i still get error "the instance for the...
1
by: Daniel Chartier | last post by:
Hello. I have a question concerning variable criteria for queries and reading forms. Let's say that I have a table with 2 fields and 10 records. One of the fields can have two different...
1
by: Dman | last post by:
MS Access 2002 - query form control returns funny symbols like I am running an append query on a form. Access is having trouble with the calculated fields and comboboxes. Example – referring...
3
by: starke1120 | last post by:
I need to write a query that has a criteria of two separate fields (one compared to another, then a seperate one) but I can't figure out how to do it. Let me first explain the table id...
10
by: FNA access | last post by:
Hello to the world of the wise, I am a CSOM student at TRU. I am trying to design a database to improve my understanding. The problem I am having is with setting up a query. I have a Query...
4
by: JPG4 | last post by:
I have tried just about everything that I can think of, so now I turn to you all for help! I have created a form (titled "OAG") with an unbound textbox titled "DOW". I also have a Query that I...
1
by: andy143vivi | last post by:
hi, just wondering how can i get a value from a text box on a different form to apply in a query, can i do this in query criteria? or i have to make a vb code in command click? i have a form with...
1
by: jeannin | last post by:
I have a table with the following text fields Status group_type query_hits PLATFORM Group_No_7 Group_No_3 I need to be able have a form which uses combo boxes as required and optional...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.