Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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…
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.

708 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