Results 1 to 2 of 2
  1. #1
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5

    Answered: Programaically detect missing references in another db

    I have a complex task coming up that requires me to analyze several hundred db's ranging in file format from mdb to accdb

    Is there any way to look at the references in another DB and determine if there are missing references in it?

    I can write the code to go through the folder structure , etc I just can't find any examples or posts regarding viewing references in another db.

    Any ideas?
    Dale Houston, TX

  2. Best Answer
    Posted by Sinndho

    "Here's a VBA procedure that will list all references (name and IsBroken status) in all Access databases in a folder. You can easily adapt it to your needs.
    Code:
    Public Sub EnumReferences(Optional ByVal Path As String)
    
        Dim appAccess As Access.Application
        Dim ref As Reference
        Dim strFileName As String
        Dim strPath As String
        
        If Len(Path) > 0 Then
            strPath = Path
        Else
            strPath = CurrentProject.Path
        End If
        If Right(strPath, 1) <> "\" Then strPath = strPath & "\"
        strFileName = Dir(strPath & "*.*db")
        Set appAccess = New Access.Application
        Do While Len(strFileName) > 0
            If strPath & strFileName <> CurrentDb.Name Then
                appAccess.OpenCurrentDatabase (strPath & strFileName)
                Debug.Print strPath & strFileName
                For Each ref In appAccess.References
                    Debug.Print , ref.Name, ref.IsBroken
                Next ref
                appAccess.CloseCurrentDatabase
            End If
            strFileName = Dir
        Loop
        Set appAccess = Nothing
        
    End Sub
    Notice that if an AutoExec macro is present in a database, it will be executed when the database is open."


  3. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Here's a VBA procedure that will list all references (name and IsBroken status) in all Access databases in a folder. You can easily adapt it to your needs.
    Code:
    Public Sub EnumReferences(Optional ByVal Path As String)
    
        Dim appAccess As Access.Application
        Dim ref As Reference
        Dim strFileName As String
        Dim strPath As String
        
        If Len(Path) > 0 Then
            strPath = Path
        Else
            strPath = CurrentProject.Path
        End If
        If Right(strPath, 1) <> "\" Then strPath = strPath & "\"
        strFileName = Dir(strPath & "*.*db")
        Set appAccess = New Access.Application
        Do While Len(strFileName) > 0
            If strPath & strFileName <> CurrentDb.Name Then
                appAccess.OpenCurrentDatabase (strPath & strFileName)
                Debug.Print strPath & strFileName
                For Each ref In appAccess.References
                    Debug.Print , ref.Name, ref.IsBroken
                Next ref
                appAccess.CloseCurrentDatabase
            End If
            strFileName = Dir
        Loop
        Set appAccess = Nothing
        
    End Sub
    Notice that if an AutoExec macro is present in a database, it will be executed when the database is open.
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •