Solved

2 conditions for query based on user input on form

Posted on 2013-11-02
3
459 Views
Last Modified: 2013-11-02
I have a report based on the following querry:

SELECT tMain.FrameLine, tMain.FrameModel, Count(tMain.FrameModel) AS CountOfFrameModel, tMain.FrameOWF, tMain.Office
FROM tMain
GROUP BY tMain.FrameLine, tMain.FrameModel, tMain.FrameOWF, tMain.Office, tMain.Status
HAVING (((tMain.FrameLine)=[Forms]![FReportSelect]![cFrameLine]) AND ((tMain.FrameOWF)=False) AND ((tMain.Office)=[Forms]![FReportSelect]![LocSelect]) AND ((tMain.Status)<>"Cancelled"))
ORDER BY tMain.FrameModel;


I would like to update the query based on [Forms]![FReportSelect]![LocSelect].  as it can either have an acutal office selection OR "All" (for all locations).

Presently it is working for a selected location but I can't find a way to have it work for "All offices.
0
Comment
Question by:thandel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 39619111
Try this:


SELECT FrameLine, FrameModel, Count(FrameModel) AS CountOfFrameModel, 
    FrameOWF, Office
FROM tMain
WHERE FrameLine) = [Forms]![FReportSelect]![cFrameLine] AND
    FrameOWF = False AND
    Status <> "Cancelled" AND
    (Office = [Forms]![FReportSelect]![LocSelect] OR [Forms]![FReportSelect]![LocSelect] = "All")
GROUP BY FrameLine, FrameModel, FrameOWF, Office, Status
ORDER BY FrameModel;

Open in new window

0
 

Author Comment

by:thandel
ID: 39619129
Error due to an extra )
0
 

Author Comment

by:thandel
ID: 39619130
Found it and that work.  Thanks
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question