Union query for 2 or many tables

J

jeanulrich00

Hi

I Have 2 access files "Fouka" and "Bouira". Each file have a table
named "Historique"with the exact same structure.

I have create another file named "Fusion"

In the file Fusion I made a link to both Historique tables (from Fouka
and Bouira)

So if I look in the table's section, I have now Historique and
Historique1

I made an union query

SELECT *
FROM [Historique]

UNION SELECT *
FROM [Historique1];

and works fine

Now, let say in the future that I have to join a third table
"Historique2" and a fourth one "Historique3"

to join all the tables, I would need to add to the union query

SELECT *
FROM [Historique2]

UNION SELECT *
FROM [Historique3];

But if for a reason I go down to only 3 links instead of 4, union
query will not work because Historique3 would not exist.

The question is

Is there another way to build a query that would join all tables named
Historique and it would not mather if I have Historique and
Historique1 or Historique and Historique1 and Historique2 or
Historique and Historique1 and Historique2 and Historique3 and
Historique4 and Historique5 and Historique6.

If this is possible, what is the code I should use

thanks
 
J

Jerry Whittle

The answer is simple: Don't do it. Keep all the data in just the two tables.
 
J

jeanulrich00

The answer is simple: Don't do it. Keep all the data in just the two tables.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.



I Have 2 access files "Fouka" and "Bouira". Each file have a table
named "Historique"with the exact same structure.
I have create another file named "Fusion"
In the file Fusion I made a link to both Historique tables (from Fouka
and Bouira)
So if I look in the table's section, I have now    Historique  and
Historique1
I made an union query
SELECT *
FROM [Historique]
UNION SELECT *
FROM [Historique1];
and works fine
Now, let say in the future that I have to join a third table
"Historique2" and a fourth one "Historique3"
to join all the tables, I would need to add to the union query
SELECT *
FROM [Historique2]
UNION SELECT *
FROM [Historique3];
But if for a reason I go down to only 3 links instead of 4, union
query will not work because Historique3 would not exist.
The question is
Is there another way to build a query that would join all tables named
Historique and it would not mather if I have Historique and
Historique1 or Historique and Historique1 and Historique2 or
Historique and Historique1 and Historique2 and Historique3 and
Historique4 and Historique5 and Historique6.
If this is possible, what is the code I should use
thanks- Hide quoted text -

- Show quoted text -

Right now I have 2 linked tables and in the future it can grow up to
10 linked files so your answer of keeping that in 2 tables is a
nonsense

Maybe you did not realy understand my question

thanks anyway
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top