Sub GetDataSources_Reports()

    Const MyTable = "MyDataSources_Reports"

    Dim db As DAO.Database

    Dim rs As DAO.Recordset

    Dim tdf As DAO.TableDef

    Dim qdf As DAO.QueryDef

    Dim fld As DAO.field

    Dim doc As Document

    Dim rpt As Report

    Dim ds As String

    '

    On Error Resume Next

    DoCmd.DeleteObject acTable, MyTable

    '

    Set db = CurrentDb

    ' create table to store the results

    Set tdf = db.CreateTableDef(MyTable)

    With tdf

        Set fld = tdf.CreateField("ReportName", dbText, 64)

        tdf.Fields.Append fld

        Set fld = tdf.CreateField("SourceType", dbText, 1)

        tdf.Fields.Append fld

        Set fld = tdf.CreateField("SourceName", dbText, 64)

        tdf.Fields.Append fld

        Set fld = tdf.CreateField("SourceSQL", dbMemo)

        tdf.Fields.Append fld

    End With

    db.TableDefs.Append tdf

    Set fld = Nothing

    Set tdf = Nothing

    '

    Set rs = db.OpenRecordset(MyTable)

    On Error Resume Next

    For Each doc In db.Containers("Reports").Documents

        rs.AddNew

        rs!ReportName = doc.Name

        DoCmd.OpenReport doc.Name, acDesign

        Set rpt = Reports(doc.Name)

        ds = rpt.RecordSource

        If ds <> "" Then

            rs!SourceName = ds

            Set tdf = CurrentDb.TableDefs(ds)

            If Err.Number = 0 Then

                rs!SourceType = "T"

            Else

                rs!SourceType = "Q"

                Err.Clear

                Set qdf = db.QueryDefs(ds)

                If Err.Number = 0 Then

                    rs!SourceSQL = qdf.sql

                Else

                    rs!SourceSQL = ds

                    Err.Clear

                End If

            End If

        End If

        '

        Set tdf = Nothing

        Set qdf = Nothing

        DoCmd.Close acReport, doc.Name, acSaveNo

        rs.Update

    Next doc

    Set db = Nothing

    '

End Sub