Skip to content

Commit 49b51e0

Browse files
Fix logic error in relations export
Do not reset the persisted reference to the CurrentDB when retrieving the relation objects from the database. The "modified only" and "all objects" cached items both share the same parent reference to the current DB. If we reassign the CurrentDB reference, it will invalidate the object references of the previously assigned relation objects.
1 parent f8d1f22 commit 49b51e0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Version Control.accda.src/modules/clsDbRelation.cls

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Implements IDbComponent
3737
'---------------------------------------------------------------------------------------
3838
'
3939
Private Sub Class_Terminate()
40+
Set m_Relation = Nothing
4041
Set m_Dbs = Nothing
4142
End Sub
4243

@@ -93,7 +94,7 @@ Private Sub IDbComponent_Import(strFile As String)
9394

9495
' Relationships create indexes, so we need to make sure an index
9596
' with this name doesn't already exist. (Also check to be sure that
96-
' we don't already have a relationship with this name.
97+
' we don't already have a relationship with this name.)
9798
If DebugMode(True) Then On Error Resume Next Else On Error Resume Next
9899
With m_Dbs
99100
.TableDefs(rel.Table).Indexes.Delete rel.Name
@@ -168,7 +169,7 @@ Private Function IDbComponent_GetAllFromDB(Optional blnModifiedOnly As Boolean =
168169
' Maintain persistent reference to database object so we don't
169170
' lose the reference to the relation object with this procedure
170171
' goes out of scope. (Make sure we release this on termination)
171-
Set m_Dbs = CurrentDb
172+
If m_Dbs Is Nothing Then Set m_Dbs = CurrentDb
172173

173174
Set m_Items(blnModifiedOnly) = New Dictionary
174175
For Each rel In m_Dbs.Relations

0 commit comments

Comments
 (0)