Query

  • Thread starter Thread starter Aaron Neunz
  • Start date Start date
A

Aaron Neunz

I have a query pointed to a table. If I import another table (same
structure) and I want to use the same query, what is the quickest way to
point it to the new table?

Thanks,
Aaron Neunz
 
Hi,

Aaron Neunz said:
I have a query pointed to a table. If I import another table (same
structure) and I want to use the same query, what is the quickest way to
point it to the new table?

If your access-version > A97

dim db as dao.database
dim qdf as dao.querydef

set db = Currentdb
set qdf = db.querydefs("YourQuery")
qdf.SQL = Replace(qdf.SQL, "OldTable", "NewTable")
db.querydefs.refresh

set qdf = Nothing
set db = Nothing

Joerg
 
I have a query pointed to a table. If I import another table (same
structure) and I want to use the same query, what is the quickest way to
point it to the new table?

Thanks,
Aaron Neunz

The quickest way would be to open the query in SQL view, copy it out
to a text editor, replace all the table names, and copy it back in.

The best way would be not to do this - instead, have a single table
and either append the imported data into it, or (if the previous
imports are no longer of interest) empty it and reload it with the
next import.
 
If your access-version > A97

dim db as dao.database
dim qdf as dao.querydef

set db = Currentdb
set qdf = db.querydefs("YourQuery")
qdf.SQL = Replace(qdf.SQL, "OldTable", "NewTable")
db.querydefs.refresh

set qdf = Nothing
set db = Nothing

<boinnnnngggg!>

Thanks Jörg; that's a new one on me, and a good one at that!
 
Back
Top