Export SQL code to table. (2 Viewers)

John Sh

Member
Local time
Tomorrow, 05:50
Joined
Feb 8, 2021
Messages
423
The code below exports the query name and the the first line only of the SQL code.
Screenshot_62.jpg


Is there a way to export the FULL SQL code to a table, or text file?

Code:
Sub ExportQueries()
    Dim db As Object
    Dim qdf As Object
    Dim rs As Recordset
    On Error Resume Next
    Set db = CurrentDb
    Set rs = oDB.OpenRecordset("Query_Temp", dbOpenDynaset)
    For Each qdf In db.QueryDefs
        If InStr(qdf.Name, "~") = 0 Then
            rs.AddNew
                rs!query_name = qdf.Name
                rs!query_text = qdf.SQL
            rs.Update
        End If
    Next qdf
End Sub
 

GPGeorge

George Hepworth
Local time
Today, 12:50
Joined
Nov 25, 2004
Messages
1,994
The code below exports the query name and the the first line only of the SQL code.
View attachment 114039

Is there a way to export the FULL SQL code to a table, or text file?

Code:
Sub ExportQueries()
    Dim db As Object
    Dim qdf As Object
    Dim rs As Recordset
    On Error Resume Next
    Set db = CurrentDb
    Set rs = oDB.OpenRecordset("Query_Temp", dbOpenDynaset)
    For Each qdf In db.QueryDefs
        If InStr(qdf.Name, "~") = 0 Then
            rs.AddNew
                rs!query_name = qdf.Name
                rs!query_text = qdf.SQL
            rs.Update
        End If
    Next qdf
End Sub
Are you sure the full SQL is not there? Have you expanded the row height of those fields to inspect the entire contents of the field?
 

John Sh

Member
Local time
Tomorrow, 05:50
Joined
Feb 8, 2021
Messages
423
Are you sure the full SQL is not there? Have you expanded the row height of those fields to inspect the entire contents of the field?
Sometimes I amaze myself, why didn't I think of that?
Thank you for the enlightenment.
 

Users who are viewing this thread

Top Bottom