I'm currently working on the main Access database of my application, and whenever I add a reference using VBA it seems to double up the reference under the Project Window.
Below is the following code I'm using:
Private Sub AddRef()
Application.References.AddFromFile ("C:\Databases\Database2.accdb")
End Sub
If I add the reference manually Tools > References, it only adds one instance of the reference.
If I use this exact code in another fresh database it only loads the reference once.
I know it's not extremely hard for Access databases to get corrupted, is that what this would be, or has anyone else experienced this issue and have an idea on how to resolve this problem?
This is the procedure I just created and ran, still doubling up in the project window. If I go to remove the reference (tools menu) it only shows once
Private Sub Test2()
Dim ref As Reference
Dim refExists As Boolean
refExists = False With CurrentProject.Application.References
For Each ref In References
If ref.name = "ARS" Then
refExists = True
End If Next
End With
If refExists = False Then
CurrentProject.Application.References.AddFromFile (CurrentProject.Path & "\Sections\ARS.accdb")
End If
End Sub
Update 5/7/18: So I figured out another part to the puzzle. If I move the databases to any other directory the procedures run correctly and the referenced database only appears once in the project window. So I don't know why it's doing it in this one specific directory but at least It shouldn't happen when I make the updates live.