View Single Post
  #4  
Old December 18th, 2009, 08:28 PM posted to microsoft.public.access.tablesdbdesign
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Change all Names: objects, fields, code, etc.

It's definitely not possible using the system tables. Not only are field
names not included there, but the system tables aren't updatable through
SQL.

If you're simply look for table and field names, you can use code like:

Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef
Dim fldCurr As DAO.Field

Set dbCurr = CurrentDb()
For Each tdfCurr In dbCurr.TableDefs
If (tdfCurr.Attributes And dbSystemObject) = 0 Then
If InStr(tdfCurr.Name, "2008") 1 Then
tdfCurr.Name = Replace(tdfCurr.Name, "2008", "2009")
End If
For Each fldCurr In tdfCurr.Fields
If InsStr(fldCurr.Name, "2008") 1 Then
fldCurr.Name = Replace(fldCurr.Name, "2008", "2009")
End If
Next fldCurr
End If
Next tdfCurr

Of course, all your queries and VBA code will now be incorrect, as well as
the forms and reports that used the old tables.

In the long run, you'd be far better off getting approval to download a
proper tool. (Well, actually you'd be far, far better off redesigning the
application correctly!)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Chris Moore" wrote in message
...
Thanks Douglas. Unfortunately downloading unapproved third party apps is
against the corporate policy so neither of these utilities is an option
for
me. I thought maybe there would be a way to do this by querying the system
tables. I took a quick look but I'm not seeing everything I would expect
to
see if that were possible. If you have any other ideas please let me know.

-Chris

"Douglas J. Steele" wrote:

If you've got tables and fields with dates in their names, your database
isn't properly designed. You've got metadata buried in the names, and
that's
a bad idea (it also makes querying far more difficult)

However, in answer to your specific question, take a look at Find &
Replace:
http://www.rickworld.com/products.html or Speed Ferret:
http://www.moshannon.com/speedferret.html

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Chris Moore" wrote in message
...
Access 02 sp3 on XP sp2.

So, I have inherited a access database from my predesessor that gathers
and
reports financial data for the previous year and current year-to-date.
As
a
result, many of the table names and column headers have names
specifically
referencing "2008" and "2009". I now need to modify this database for
the
approaching new year. Everything that says "2008" will need to be
changed
to
"2009" and everything that says "2009" will need to be changed to
"2010".
Unfortunately this also means that all the queries, forms and modules
that
reference these names also need to be updated. In short it's a mess.

Is there any way to globally search a database for any and all
references
to
a particular value and replace that value with another? It's all just
code
after all, right?

Thanks in advance for any help offered.

-Chris



.