Full Version: Show Records as tables
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
mkkashif
hi,
i want to show the 2 tables records in a query as table.
how it possible.
have a look attach db.
i want that the B & C tables Records like in the show.txt (attachfile)
is this possible to show the two tables records as a table view
i don't want that the records show in right of the query
i want to show B Table Records in Top
and C Table Records Below.
Like This.
B Table Records
C Table Records.
Normaly Records Shows Like This in Select Query.
B Table Records C Table Records
thanks for your help
niesz
You will need to use a UNION query like:

SELECT c.CustomerId, c.Invoiceno, c.info, Null AS PaymentReceived, 1 AS SortOrder
FROM c

UNION ALL
SELECT B.CustomerID, Null AS InvoiceNo, Null AS Info, B.PaymenReceived, 2 AS SortOrder
FROM B
ORDER BY CustomerID, SortOrder
mkkashif
Dear
thanks a lot for kind help.
i exactly need this query.

is there any easy way to write union query as we can easily create the select query by design view.
or it must have to write.
i mean we can't use like Design View in the query section .


and if we have a field in both tables "InvoiceDate","TranDate".
how can we arrange the records by date.
i mean if C table invoice date is 02-21-06 and
B table TransDate is 02-22-06 and so on.
the query should show the record First C Table and Then B Table Records and so on sorting by Date.

is this right expression.
SELECT c.CustomerId, c.Invoiceno, c.info, Null AS PaymentReceived, 1 AS SortOrder
FROM c
WHERE (((c.CustomerId)=[enter id]))
UNION ALL SELECT B.CustomerID, Null AS InvoiceNo, Null AS Info, B.PaymenReceived, 2 AS SortOrder
FROM B
WHERE (((B.CustomerId)=[enter id]))
ORDER BY CustomerID, SortOrder;
niesz
UNION queries cannot be visually designed with the QBE grid. They must be manually created. You can create each section separately and paste them one by one into the SQL pane and then just type the word "UNION" or "UNION ALL" in between them. This should get you 99% of what you need. You can learn more about UNION queries through Access Help or if you have specific questions you can post them here on UA.

If you need to sort on a field, the ORDER BY clause goes at the end of all the SELECT statements. The reason I added the SortOrder field in my example is so that the records would be displayed in the order you originally asked. There was no date field given in the example. But you can easily add this field and sort on it too.
mkkashif
thanks very much for your kind help.
niesz
Glad to help.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.