Name of table being queried. (1 Viewer)

llkhoutx

Registered User.
Local time
Today, 00:12
Joined
Feb 26, 2001
Messages
4,018
How can I reference the name of the (single) table being queried in a column field with the table anme as a function argument? I'm using multiple tables names in a complex function and in multiple queries. I don't want to hardcode the table name.:banghead::mad:

I can generate a series of same by building the SQL string, but those that there might be a better way.

Any suggestions?
 

jdraw

Super Moderator
Staff member
Local time
Today, 01:12
Joined
Jan 23, 2006
Messages
15,378
Depends on where you may be doing this, I think. If you had a combo on a form, and you could select the table name from the combo.

If you had a table of table and field names, you could use that table in a recordset. If you were doing something in a loop, you could iterate the table that houses this data.

But it might be more helpful if you gave us a sample or more info about your situation.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:12
Joined
Feb 19, 2002
Messages
43,257
Your only option is embedded SQL strings generated by VBA. There is no way to change something structural in a querydef. And a table name is structural. Access creates an execution plan the first time it runs a querydef and saves it for later use. If you changed a table, that wouold void the saved execution plan and require re-analysis by the database engine to calculate a new execution plan. You may "know" the structure is identical and the indexes are identical and the rowcounts are identical but the db engine does not and so it doesn't allow this. NO RDBMS will allow it. This is not a limitation of Access.
 

Users who are viewing this thread

Top Bottom