COlumn in query with table name

John liem

Registered User.
Local time
Today, 19:06
Joined
Jul 15, 2002
Messages
112
How can I create a column in a query that reflects automatically the table name? Example: Table_ABC. has fields: ID, Material, Qty. I want to create automatically a column/field in the Qy_ABC with "ID", "Material" and "QTY", and in additon into it, next to "Qty" a filed/column is called "Name" and filled with "ABC". Thanks.
 
Select ID, Material, QTY, "ABC" As TableName
From Table_ABC;

"Name" is a poor choice as a column name since it is also the name of a property and will cause problems if you ever need to use the query in VBA. Also, ID is a poor choice as a key name. Common practice is to use the table name in conjunction with ID. Such as CustomerID, ProductID, ClassID, etc.
 
Pat, Thanks for your suggestions and solution.
 

Users who are viewing this thread

Back
Top Bottom