?
Solved

2 conditions for query based on user input on form

Posted on 2013-11-02
3
Medium Priority
?
474 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 93

Accepted Solution

by:
Patrick Matthews earned 2000 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

762 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