views:

60

answers:

2

so I have inherited an Access DB with different naming conventions applied to tables. It hurts my eyes, and I want to refactor. Code isn't a problem, but what about SQL embedded in the queries?

Going to answer my own question crudely now, but can anyone come up with a better method?

A: 
For Each qdf In CurrentDb.QueryDefs
    CurrentDb.Execute "insert into qdfs (name, sql) select '" & qdf.Name & "','" & Replace(qdf.sql, "'", "''") & "'"
Next qdf

Then I can apply a filter to my new qdfs table, and at least figure out where I'd need to look to rename tables..

Nick
Nick, Refer to the "Find and Replace tool" below. You need to find **ALL** the objects,e.g. Forms, Reports, etc. that use the Table/Field/Query that you are renaming and then apply the change consistently. PS Make sure you have a good backup!
heferav
+3  A: 

You might want to check out Rick Fisher's "Find and Replace" tool. I think it would do what you want. It does search and replace throughout Access's objects: forms, reports, queries, etc. I liked it a lot when I used it several times quite a few years ago:

http://www.rickworld.com/products.html

I think there used to be at least one other similar comprehensive search and replace tool for Access databases, don't remember its name or know whether it's still around.

Herbert Sitz
Agreed on Rick Fisher's tool. I've been using it for about 15 years or so. See the Scan and replace utilities section at the Microsoft Access third party utilities, products, tools, modules, etc. page at my website. granite.ab.ca/access/thirdparty.htm
Tony Toews
The Access 2003 development tools also installs are rather slick little property scanner. It can't do replaces, though.
David-W-Fenton
+1's all round for the useful pointers
Nick