Solved

2 conditions for query based on user input on form

Posted on 2013-11-02
3
453 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
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

828 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