S
Stephen J. Levine
How do I change a relationship in visual basic so that
referential integrity is enabled?
I have tried doing it as a relation, attempting to set the
attributes to 0. I have also tried to do it as an object,
setting the property "attributes" to 0.
Either way, I get the error message Runtime Operation
3219, Invalid operation.
My code is:
Option Compare Database
Option Explicit
Dim RmteDb As Database, Relship As Relation, i As Integer,
LocalDB As Database
Dim RelRst As Recordset, RelshipObj As Object
Function update_relationship()
Set RmteDb = OpenDatabase(CurrentProject.Path & "\OBI
EMTS Devl database.mdb")
Set LocalDB = CurrentDb
Set RelRst = LocalDB.OpenRecordset("relationships
query", dbOpenDynaset)
RelRst.MoveFirst
Do While Not RelRst.EOF
If RelRst!ReloldAttributes <> 0 Then
Set RelshipObj = RmteDb.Relations(RelRst!
RelName)
RelshipObj.Properties("Attributes") = 0
End If
Debug.Print Relship.Name, Relship.Table,
Relship.ForeignTable
Debug.Print Relship.Attributes
Debug.Print Relship.Properties.Count
Loop
Close
Debug.Print "Completed"
End Function
The line that fails is "RelshipObj.Properties
("Attributes") = 0"
I hope I do not have to remove and recreate the
relationship.
sjl
referential integrity is enabled?
I have tried doing it as a relation, attempting to set the
attributes to 0. I have also tried to do it as an object,
setting the property "attributes" to 0.
Either way, I get the error message Runtime Operation
3219, Invalid operation.
My code is:
Option Compare Database
Option Explicit
Dim RmteDb As Database, Relship As Relation, i As Integer,
LocalDB As Database
Dim RelRst As Recordset, RelshipObj As Object
Function update_relationship()
Set RmteDb = OpenDatabase(CurrentProject.Path & "\OBI
EMTS Devl database.mdb")
Set LocalDB = CurrentDb
Set RelRst = LocalDB.OpenRecordset("relationships
query", dbOpenDynaset)
RelRst.MoveFirst
Do While Not RelRst.EOF
If RelRst!ReloldAttributes <> 0 Then
Set RelshipObj = RmteDb.Relations(RelRst!
RelName)
RelshipObj.Properties("Attributes") = 0
End If
Debug.Print Relship.Name, Relship.Table,
Relship.ForeignTable
Debug.Print Relship.Attributes
Debug.Print Relship.Properties.Count
Loop
Close
Debug.Print "Completed"
End Function
The line that fails is "RelshipObj.Properties
("Attributes") = 0"
I hope I do not have to remove and recreate the
relationship.
sjl