remove relationship programaticaly

N

Norylo

Is It possible to remove relationships between tables, programaticaly,
without Access IDE. I need that because of huge reorganisation. When I use:
DROP INDEX PrimaryKey ON tblItems, that is parent to tblItemDetail I get an
error message:
Cannot delete index it is either the current index or is used on relationship.
I know how to solve this on local computer within IDE Tools, but I am using
ASP so I have to do remotely, by script.
Thanx for help.
 
P

Paul Overway

Yes...this should give you an idea of what needs to be done...

Dim dbe
Dim wrk
Dim db
Dim rel
Dim strRelName

Set dbe = CreateObject("DAO.DBEngine.36")
dbe.SystemDB = "path to MDW" 'Use system.mdw or omit this line, if
database isn't secure
Set wrk = dbe.CreateWorkspace("whatever","User Name Here","password
here") 'Admin and "" if unsecured database
Set db = wrk.OpenDatabase("path to MDB")

For each rel in db.Relations
If rel.Table = "The Table" And rel.ForeignTable = "The Related
Table" Then
strRelName = rel.Name
Exit For
End if
Next

db.Relations.Delete strRelName
 
T

Tim Ferguson

Is It possible to remove relationships between tables, programaticaly,
without Access IDE. I need that because of huge reorganisation.

ALTER TABLE DROP CONSTRAINT etc



HTH


Tim F
 
Top