Solved

Query designer question

Posted on 2013-01-17
4
238 Views
Last Modified: 2013-01-19
I'm trying to figure out how to create a select query that will pull records from two different tables if they have a common field name.  

Example:

tblOpenOrders and tblFinGoods

both have a field named "PartN" and I want the query to return all the records from tblOpenOrders AND ALSO all the records from tblFinGoods using form criteria like:

Forms!frmCloseOrder!txtPartN

So if tblOpenOrders has 5 records equal to "Forms!frmCloseOrder!txtPartN" and tblFinGoods has 10 records equal to "Forms!frmCloseOrder!txtPartN" I want 15 records to display when I run the query.

Possible?

--Steve
0
Comment
Question by:SteveL13
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
MMTadmin earned 500 total points
ID: 38789756
select [fields] from table 1 where [this] = that

union

select  [fields] from table 2 where [this] = that
0
 
LVL 2

Expert Comment

by:MMTadmin
ID: 38789757
the fields must be the same for a union

research union it has some quirks
0
 
LVL 26

Expert Comment

by:jerryb30
ID: 38789777
Not for points:

select * from table1
where partN = Forms!frmCloseOrder!txtPartN
union all
select * from table2
where partN = Forms!frmCloseOrder!txtPartN

Union
 will automatically group like values (for all fields)

Union all

allows like values (for all selected fields), although the source table would be lost.
0
 
LVL 20

Expert Comment

by:clarkscott
ID: 38792055
If you tables are different, create a query for each table and name the columns the same for both queries.  Use these 2 new queries in your union query.

Scott C
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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…

911 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

15 Experts available now in Live!

Get 1:1 Help Now