By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,931 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,931 IT Pros & Developers. It's quick & easy.

Delete table and associated relationships

P: n/a
AP
When developing, I have a production version that is being used by
users, and as I develop, I periodically import the key data tables into
my development version. There are about 4 tables and I list them in a
table and have code to loop through the table to import them all in
batch. The problem is, if one of the tables is associated with a
relationship I have to delete it manually. How do I delete them with
the table, they relationships 'come back' to the database on the
import, so its not a big deal for me to get rid of the temporarily.

This is the code I am using to delete the tables:
DoCmd.DeleteObject acTable, strDest
where 'strDest' is the table name.

Thanks

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
If you know the name of the relation, you can kill it with:
DBEngine(0)(0).Relations.Delete "MyRelation"

If you need to loop through the Relatoins:

Function ShowRel()
Dim db As DAO.Database
Dim rel As DAO.Relation
Dim fld As DAO.Field

Set db = CurrentDb()
For Each rel In db.Relations
Debug.Print rel.Name, rel.Table, rel.ForeignTable, rel.Attributes
For Each fld In rel.Fields
Debug.Print , fld.Name, fld.ForeignName
Next
Next

End Function

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"AP" <ap******@thompsongroup.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
When developing, I have a production version that is being used by
users, and as I develop, I periodically import the key data tables into
my development version. There are about 4 tables and I list them in a
table and have code to loop through the table to import them all in
batch. The problem is, if one of the tables is associated with a
relationship I have to delete it manually. How do I delete them with
the table, they relationships 'come back' to the database on the
import, so its not a big deal for me to get rid of the temporarily.

This is the code I am using to delete the tables:
DoCmd.DeleteObject acTable, strDest
where 'strDest' is the table name.

Thanks

Nov 13 '05 #2

P: n/a
AP
Thanks
I was able to use that to do what I needed.

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.