I'm trying to figure out why you need it to be automatic. It implies
that you don't know at design time what table the query will be running
against. The only scenario where that is even possible is if you are
using dynamic sql to insert the table's name into the FROM clause of a
sql string. In that case, all you need to do is insert the tablename
into an expression within the string.
The goal would be:
Select ... "mytable" as SrcTable, ... FROM mytable
the VBA code would be:
dim tblname as string,sql as string
tblname = "mytable"
sql="Select ... """ & tblname & """ as SrcTable, ... FROM " & _
tblname