Solved

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

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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

733 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