COlumn in query with table name (1 Viewer)

John liem

Registered User.
Local time
Today, 05:57
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.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 23:57
Joined
Feb 19, 2002
Messages
43,774
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.
 

John liem

Registered User.
Local time
Today, 05:57
Joined
Jul 15, 2002
Messages
112
Pat, Thanks for your suggestions and solution.
 

Users who are viewing this thread

Top Bottom