Query

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
 
J

Jörg Ackermann

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
 
J

John Vinson

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.
 
J

John Vinson

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top