Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Is there a way to consolidate 3 queries into 1 query in an Access 2003 application?

Posted on 2013-11-07
1
Medium Priority
?
383 Views
Last Modified: 2013-11-08
I am developing an Access 2003 application that uses 3 queries as follows:
Is there a way to consolidate these 3 queries into 1 query?

1) qryOIDetailsModSrADE =
SELECT tblBanks.*, tblDates.dtRec, tblOpenItems.*
FROM tblDates, tblBanks INNER JOIN tblOpenItems ON tblBanks.[Bank Code]=tblOpenItems.Bank
WHERE tblOpenItems.t In ("A","D","E");

2) qryOIDetailsModSrBC =
SELECT tblBanks.*, tblDates.dtRec, tblOpenItems.*
FROM tblDates, tblBanks INNER JOIN tblOpenItems ON tblBanks.[Bank Code]=tblOpenItems.Bank
WHERE tblOpenItems.t In ("B","C");

3)
qryMonthlyOpenItemsDetails =
SELECT [Process Date], [Trans Date], [Bank Code] AS [BRS#], [GLAcct#] As [Taps/Margin], [ACCOUNT#]
As [Bank Account Number], T As [_Type], tblOpenItems.Type As [Trans Code], Description, [Office] & ' '
& [CheckNum] As [Check/Reference#], Amount, AgeDays As [Age(Days)], footnote As Comments,
tblBanks.[REPORT NAME] As Responsibility, tblBanks.Currency,tblBanks.[Senior Management Tab]
FROM qryOIDetailsModSrADE
WHERE (tblBanks.[SENIOR MANAGEMENT TAB] <>"NA");
UNION ALL SELECT [Process Date], [Trans Date], [Bank Code] AS [BRS#],  [GLAcct#] As [Taps/Margin],  
[ACCOUNT#] As [Bank Account Number],T As [_Type], tblOpenItems.Type As [Trans Code], Description, [Office]
& ' ' & [CheckNum] As [Check/Reference#], Amount, AgeDays As [Age(Days)], footnote As Comments,
tblBanks.[REPORT NAME] As Responsibility,  tblBanks.Currency, tblBanks.[Senior Management Tab]
FROM qryOIDetailsModSrBC
WHERE (tblBanks.[SENIOR MANAGEMENT TAB] <>"NA")
ORDER BY [Age(Days)] DESC;
0
Comment
Question by:zimmer9
1 Comment
 
LVL 25

Accepted Solution

by:
chaau earned 2000 total points
ID: 39632586
Yes it is possible. The select statements in your UNION ALL are exactly the same, and the code for the queries is similar. I would do it like this:

SELECT [Process Date], [Trans Date], [Bank Code] AS [BRS#], [GLAcct#] As [Taps/Margin], [ACCOUNT#]
As [Bank Account Number], T As [_Type], tblOpenItems.Type As [Trans Code], Description, [Office] & ' '
& [CheckNum] As [Check/Reference#], Amount, AgeDays As [Age(Days)], footnote As Comments,
tblBanks.[REPORT NAME] As Responsibility, tblBanks.Currency,tblBanks.[Senior Management Tab]
FROM tblDates, tblBanks INNER JOIN tblOpenItems ON tblBanks.[Bank Code]=tblOpenItems.Bank
WHERE tblOpenItems.t In ("B","C","A","D","E") AND (tblBanks.[SENIOR MANAGEMENT TAB] <>"NA")
ORDER BY [Age(Days)] DESC;

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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 …
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

926 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