How to rename a Table and Not to loose the relations

  • Thread starter javiernews via AccessMonster.com
  • Start date
J

javiernews via AccessMonster.com

Hi,
How can I rename a Table and Not to loose the releations ???

I use the following code:
DoCmd.Rename strNewName, acTable, strOldName

Thank you !
 
D

David H

In the OPTIONS dialog under the GENERAL tab is an option to turn on 'Name
Auto Correct', which *should* take care of propagating any name changes
throughout the database.

I would however make a backup first.

Also, I've read some posts about Name Correct occasionally causing problems
when its turned on. I don't remember specifically what the issues were as I
personally never use it, however you may want to google around just to be
aware of any possible issues.
 
J

javiernews via AccessMonster.com

Thank you David & Alex , for yours answers but,.........

Yes ofcourse I can make it manually every time,.....(pressing the button
'show all relationships' )
but,.......... How to make it automatically (may by code)
Is this possible ????
 
D

David H

When NAME AUTO CORRECT is turned on, Access should automatically update any
instance where the object is referenced to the new name - including the
relationships. In short, turn NAC on and when you rename the table, Access
will handle automatically updating the relationships.

Make a copy of the database and then in the copy turn NAC on and change the
table name, you should see that the relationships are then preserved.

http://msdn.microsoft.com/en-us/library/aa139941(office.10).aspx
http://office.microsoft.com/en-us/access/HA010345661033.aspx

I did find this article which should make you aware of the issues
surrounding NAC
http://allenbrowne.com/bug-03.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top