Solved

2 conditions for query based on user input on form

Posted on 2013-11-02
3
423 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
Comment Utility
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
Comment Utility
Error due to an extra )
0
 

Author Comment

by:thandel
Comment Utility
Found it and that work.  Thanks
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now