Changing Tables in Query Design

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I frequently need to change the source table in my queries. Eg. 10-1-05 to
10-15-05 to 11-1-05.

I open up the previous query, then add the new table, delete the previous
one, then wish to change which table is being used for a record source. The
fields in both tables are the same.

Is there a shortcut to changing the source fields without doing each field
individually? Sort of a search and replace for tables?

Thank you!
 
Having dates in the source table name and having to change the referenced
table are both indicators of a structural design problem.

That said, you can make your life easier by using an alias for your source
table. Then you only have to change one thing in the code.

If you have SQL that looks like:
SELECT T.Field1, T.Field2
FROM Table1 as T
WHERE T.Field3 Like "Abs*"

All you need to do to use Table2 is make one change.
SELECT T.Field1, T.Field2
FROM Table2 as T
WHERE T.Field3 Like "Abs*"

If you are doing this in the query grid
Double-click in the grey area to show properties
Click on the Title of the table
Change the Alias from the table name to "MyDateNameTable" or whatever you
want it to be.

Now switch to the SQL view (Menu: View: SQL)
Find the any reference to 10-1-05 and change it to 10-15-05 (make sure you
get the square braces [] ) You will probably only need to change ONE
reference.
 
Back
Top