Export all MS Access SQL queries to text files

后端 未结 5 1528
失恋的感觉
失恋的感觉 2020-12-08 07:32

I have to document an MS Access database with many many macros queries, etc. I wish to use code to extract each SQL query to a file which is named the same as the query, eg

5条回答
  •  清歌不尽
    2020-12-08 08:03

    This solution include fields in query

    Public Sub ListQueries()
        ' Author:                     Date:               Contact:
        ' André Bernardes             09/09/2010 08:45    bernardess@gmail.com     http://al-bernardes.sites.uol.com.br/
        ' Lista todas as queries da aplicação.
        ' Listening:
    
        Dim i As Integer
        Dim j As Integer
        Dim k As Integer
        Dim l As Integer
    
        On Error Resume Next
    
        For i = 0 To CurrentDb.QueryDefs.Count - 1
            Debug.Print "Query: " & CurrentDb.QueryDefs(i).Name
    
            For j = 0 To CurrentDb.QueryDefs(i).Fields.Count - 1
                Debug.Print "Field " & CurrentDb.QueryDefs(i).Fields(j).Name
            Next
    
            Debug.Print "  SQL: " & CurrentDb.QueryDefs(i).SQL
        Next
    End Sub
    

提交回复
热议问题