Changing the source of a query

C

Carissa

I have several queries that are linked to a table in my database. I would
like to replace this table with a query containing the same fields. However,
I'm afraid that I'm going to have to manually change the source of each field
in my origional queries.

Is there a way to change the source for all fields in a query at once?
Thanks!
 
O

Ofer Cohen

First make a back up to your mdb

You can try something like

Application.CurrentDb.QueryDefs("QueryName").SQL =
Replace(Application.CurrentDb.QueryDefs("QueryName").SQL,"TableName","NewQueryName")

This code will replace the table name with the query name
 
Top