Re: delete row blocked by non-existant relationship



On Thu, 9 Jun 2005 12:01:20 -0700, Leslie S. <Leslie
S.@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

>Running Access 2003 on Windows 2000.
>
>I have developed a database, no data in it yet. Once I was almost finished
>with my basic design, I had to change the field name and size that I am using
>for my primary key in one table and delete the unused field of the same name,
>size, type from another. I checked the relationships window and selected show
>all relationships. In the first table, no relationships had been established
>yet. In the second table one relationship exists but not to the field in
>question.


You might need to use this small nuclear device (back up your database
FIRST):

Sub KillAllRelations()
Dim db As DAO.Database
Dim rel As Relation
Dim inti As Integer
Set db = DBEngine(0)(0)
For inti = db.Relations.Count - 1 To 0 Step -1
Set rel = db.Relations(inti)
Debug.Print "Deleting relation "; rel.Name, rel.Table,
rel.ForeignTable
db.Relations.Delete rel.Name
Next inti
End Sub


It does just what it says - deletes all relationships, visible or not.
You can adapt it to be more selective (for instance by checking the
Table and ForeignTable properties before deleting the relation).

John W. Vinson[MVP]
.