Skip to content

Commit

Permalink
Fix logic error in relations export
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joyfullservice committed Jul 5, 2023
1 parent f8d1f22 commit 49b51e0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Version Control.accda.src/modules/clsDbRelation.cls
Expand Up @@ -37,6 +37,7 @@ Implements IDbComponent
'---------------------------------------------------------------------------------------
'
Private Sub Class_Terminate()
Set m_Relation = Nothing
Set m_Dbs = Nothing
End Sub

Expand Down Expand Up @@ -93,7 +94,7 @@ Private Sub IDbComponent_Import(strFile As String)

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

Set m_Items(blnModifiedOnly) = New Dictionary
For Each rel In m_Dbs.Relations
Expand Down

0 comments on commit 49b51e0

Please sign in to comment.