473,395 Members | 1,454 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Query Table Name

I union several tables by query. And I plan to use table name to identify data source. Any one can help?

Thnaks
Jan 23 '07 #1
7 2990
nico5038
3,080 Expert 2GB
Just use the UNION query in a maketable and/or createtable query.

Nic;o)
Jan 23 '07 #2
Just use the UNION query in a maketable and/or createtable query.

Nic;o)

My main problem in to get Table Name as a result of query.
Jan 23 '07 #3
nico5038
3,080 Expert 2GB
Hmm, guess the way then is to use:

select "tblA" as Origin, * from tblA
UNION
select "tblB" as Origin, * from tblB
UNION
select "tblC" as Origin, * from tblC
UNION
etc.

Is the way. To automate the fill of the field [Origin] you'll have to construct the query in code.

Nic;o)
Jan 23 '07 #4
Hmm, guess the way then is to use:

select "tblA" as Origin, * from tblA
UNION
select "tblB" as Origin, * from tblB
UNION
select "tblC" as Origin, * from tblC
UNION
etc.

Is the way. To automate the fill of the field [Origin] you'll have to construct the query in code.

Nic;o)

You are righ. That will fill in fixed value "tblA",... in to the field Origin. But what I'm after is sql get "tblA",... itself without my input, just read it from From table. In Excel, there is a function to recall current worksheet name into the cel.

Thanks for help.
Jan 23 '07 #5
nico5038
3,080 Expert 2GB
There's a hidden "Msys" system table holding the tablenames, but I don't know a way to dynamically get the name of a query.
I would use VBA to construct the UNION query from code and just itterate through the querydef collection to get the tablename and string the fixed value in the select statement.
The querydef can be managed from code like:

dim qd as querydef

set qd = currentdb.querydefs("qryUNION")

' here create the SQL e.g. in strSQL and use:

qd.SQL = strSQL

' Now the query is saved and can be activated.

Nic;o)
Jan 23 '07 #6
MMcCarthy
14,534 Expert Mod 8TB
This query will at least give you the list of table names.

Expand|Select|Wrap|Line Numbers
  1. SELECT MSysObjects.Name
  2. FROM MSysObjects
  3. WHERE (((MSysObjects.Type)=1) AND ((MSysObjects.Flags)=0));
Jan 24 '07 #7
NeoPa
32,556 Expert Mod 16PB
I union several tables by query. And I plan to use table name to identify data source. Any one can help?

Thnaks
I've read all three of your posts so far and I'm really not sure what you want exactly.
Can you try to explain clearly exactly what you are trying to achieve.
This way we can stop guessing and answer your question directly.

MODERATOR.
Jan 24 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: B. Fongo | last post by:
I learned MySQL last year without putting it into action; that is why I face trouble in formulating my queries. Were it a test, then you would have passed it, because your queries did help me...
3
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
3
by: John Baker | last post by:
Hi: At the outset let me admit that I screwed up! I have built a rather elaborate set of forms and sub forms starting with a client table, and going down to PO and Line item. This works very...
3
by: GL | last post by:
Hi, Is there a way to add a field to an existing table using a query of some sort (without needing to manually add a field to the table). I know how to do it with a make table query, but I have...
8
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: ...
2
by: Venk | last post by:
hi all, I saw one reply to arun on the subject "Dynamic Query in Ms-Access" by one Mr Rick I found it very useful. Now to extend this solution forward I have the following situation. I...
0
by: phlype.johnson | last post by:
I'm struggling to find the best query from performance point of view and readability for a normalized DB design. To illustrate better my question on whether normalized designs lead to more complex...
2
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
How can I run this query against a table in my Access database? I don't know hwo to use it in C#. In VB I would use .Recordset = "some sql statement". How do I do this in C#? //I get a vlaue...
5
by: wugon.net | last post by:
question: db2 LUW V8 UNION ALL with table function month() have bad query performance Env: db2 LUW V8 + FP14 Problem : We have history data from 2005/01/01 ~ 2007/05/xx in single big...
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.