Full Version: Using a qry to extract info from a table name to a field
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
MCK
I am trying to run a query that allows me to take the right 6 characters of the table name and insert them into a field within the table.
Doug Steele
You're going to have to hard-code the 6 characters: I don't believe there's any way in a query to get access to the table's name.
doctor9
This query will give you the list of table names:

SELECT MSysObjects.Name AS nm, MSysObjects.Database
FROM MSysObjects
WHERE (((MSysObjects.Database) Is Not Null));

It also lists the path/name of the database file that the table resides in. I use it to manage tables linked from multiple databases.

Dennis
Doug Steele
While you can get the information about the tables in an application from MSysObjects, I don't think that's what MCK is looking for.

I'm assuming he/she wants to be able to put the last 6 characters of a particular table as a field in that table.
doctor9
MCK,

Firstly, welcome to UtterAccess! (Um, a little belated, I admit.)

Secondly, can you be more specific about what you are doing with an example?

That way we can better help you accomplish your task.

Dennis
truittb
Welcome to Utter Access.

What you want to do begs the question why? Do you have multiple tables with the same structure? confused.gif

Let us know why you need to do what you are asking.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.