Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automate rename table

Status
Not open for further replies.

markbrum

Technical User
Mar 10, 2003
46
0
0
GB
Hi,

In have a macro running which processes some data. To get the data in I use

DoCmd.RunCommand acCmdLinkTables

The user selects the table they wish to process and it is linked but it is named as per the table they selected. I would like the link to be automatically renamed to a standard name I set so that I can reference it.

One thing that's possible is that I could say rename all tables to 'whatever' because there will only ever be that one table, but I am not sure how to do this in VBScript.

Help!

Thanks, Mark.
 
Try this...

Code:
Dim db as Database
Dim tbl as TableDef

Set db = CurrentDb()
Set tbl = db.TableDefs("OldTableName")
tbl.Name = "NewTableName"

Set tbl = Nothing
Set db = Nothing
 
Sorry I don't understand. The point is that I don't know what the old table name is. The reason why I need to change the name is so that I can reference it.

What I'm asking for is some code which says either:
'change name of table i just linked to 'whatever'
or
'change name of all tables (there will only be one) to 'whatever'

the old table name will be different every time the database is used so I can't hard-code it into the app.
 
If there will only be one table, use this line to get the reference to your table...

Set tbl = db.TableDefs(0)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top