Deleting Relationships Programatically (1 Viewer)

Libre

been around a little
Local time
Yesterday, 22:41
Joined
May 3, 2007
Messages
660
Hi - I'm new here, and I hope you don't mind if I jump right in with a question.

Suppose I want to delete a table, programatically. I could write:
DoCmd.DeleteObject acTable, "myTable"

Now, that would work, unless the table was related to another table, and then I would get this error-
Run Time Error '2387':
You can't delete the table 'myTable'; it is participating in one or more relationships.

Can anyone tell me how to delete the relationship, programatically, before executing the delete table command?

In fact, what I REALLY want to do is to delete ALL the relationships, and then ALL the tables in the entire db.
And of course, I want to do it all programatically, not by selecting the objects and hitting the delete key.

Any help would be greatly apprecitated. Thanks in advance.
 

dsigner

Registered User.
Local time
Today, 06:41
Joined
Jun 9, 2006
Messages
68
If you delete all tables and all relationships then anything else like a query or form will fail so you would be just as well opening a new clean database. If there is something in the old one which you want just copy it across.
 

Dennisk

AWF VIP
Local time
Today, 06:41
Joined
Jul 22, 2004
Messages
1,649
I think you need to open the schema to add or remove relationships.
 

Libre

been around a little
Local time
Yesterday, 22:41
Joined
May 3, 2007
Messages
660
dsigner-
I guess I should explain why I would want to delete all the tables.
You see, I have an installation of my db here at work, that is under development. But we still use it extensively even though I am continuing to add functions and develop it.

When I go home, I often continue development on an "off-line" copy of the db, while here at work they continue to use the program, add and edit records, etc.
Next day at work, I have to integrate the NEW (updated) front end (forms, queries, etc) that I have been working on with the current "production" copy that now has updated records. It is time consuming and laborious. And somtimes I have lost some updates.
So I figured, why not just delete ALL the tables from the NEW db and then replace them with the tables from the PRODUCTION db? Then I'd have a db with my front-end updates and all the current data.

I realize that another way of going about this is to SPLIT the db and link the front end to the tables - but I've had mixed results trying this - we are in a windows LAN environment. But perhaps that is where I should devote my efforts. After all, that is what I essentially want to do, by deleting and replacing all the tables.

Dennisk-
Don't know what the "schema" is. Is that the relationships lay-out?
 

Dennisk

AWF VIP
Local time
Today, 06:41
Joined
Jul 22, 2004
Messages
1,649
Hi,

Open a code module then open help and enter relationship. A help topic will appear for the relationship collection (sorry not schema thats ADOX) it will show you how to retrieve and set up relationships using VBA.
 

Users who are viewing this thread

Top Bottom