PC Review


Reply
Thread Tools Rate Thread

Create a list of tables

 
 
Joe
Guest
Posts: n/a
 
      6th Jul 2004
Hello All:
I'm looking to create a list of all of the tables in a
dB. I would like to edit this list using the rename
method. My goal is simply to rename all of the tables in
bulk. I only need to remove a prefix from each table.
Thanks in advance for any help.
Joe
 
Reply With Quote
 
 
 
 
Gerald Stanley
Guest
Posts: n/a
 
      6th Jul 2004
Here is some sample code that removes the dbo_ prefix from
tables.

Dim db As DAO.Database
Dim tbl As DAO.tabledef

Set db = CurrentDb
For Each tbl In db.TableDefs
If Left$(tbl.Name, 4) = "dbo_" Then
tbl.Name = Mid$(tbl.Name, 5)
End If
Next

Hope This Helps
Gerald Stanley MCSD
>-----Original Message-----
>Hello All:
>I'm looking to create a list of all of the tables in a
>dB. I would like to edit this list using the rename
>method. My goal is simply to rename all of the tables in
>bulk. I only need to remove a prefix from each table.
>Thanks in advance for any help.
>Joe
>.
>

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      6th Jul 2004
"Joe" <(E-Mail Removed)> wrote in message
news:2729b01c4635e$5c89b1e0$(E-Mail Removed)
> Hello All:
> I'm looking to create a list of all of the tables in a
> dB. I would like to edit this list using the rename
> method. My goal is simply to rename all of the tables in
> bulk. I only need to remove a prefix from each table.
> Thanks in advance for any help.
> Joe


Code along these lines should do it:

'----- start of procedure -----
Sub RemoveTablePrefix(strPrefix As String)

Dim db As DAO.Database
Dim tdf As DAO.TableDef

If strPrefix = "MSys" Then
Msgbox "You may not rename system tables!"
Exit Sub
End If

Set db = CurrentDb
For Each tdf In db.TableDefs
If tdf.Name Like strPrefix & "*?" Then
tdf.Name = Mid(tdf.Name, Len(strPrefix) + 1)
End If
Next tdf
Set db = Nothing
Application.RefreshDatabaseWindow

End Sub

'----- end of procedure -----

You'd call it like this:

RemoveTablePrefix "xxx"

(where "xxx" is the prefix to be removed).

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create tables on multiple sheets from list monden2 Microsoft Excel Programming 3 13th Apr 2010 01:18 PM
How do I create a List of Tables? =?Utf-8?B?Sm95?= Microsoft Word Document Management 3 29th Mar 2007 02:37 AM
Create List of Queries, Tables & Reports =?Utf-8?B?YnJpYW5r?= Microsoft Access Queries 4 28th Jun 2006 02:55 PM
The pivot tables 101 article says to use the "Create List" comman. =?Utf-8?B?Y2dub2xhbmQwMw==?= Microsoft Excel New Users 2 14th Jan 2005 11:39 PM
How to create List of Figures/Tables for seperate documents Jessica Xu Microsoft Word New Users 2 15th Jan 2004 06:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:26 AM.