Solved

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

Posted on 2013-11-07
1
373 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 24

Accepted Solution

by:
chaau earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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…

929 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

11 Experts available now in Live!

Get 1:1 Help Now