Hello --
I want to export to text the SQL version of all queries in a 2010 mdb.
This code runs in 2003. VBA is not my strength.
Can anyone give me pointers on how to adapt it to 2010?
The first error message is on this line:
Dim dbs As Database ... "User-defined type not defined"
Thanks in advance for any help.
Public Function ExportObjects()
Dim dbs As Database
Dim ctr As Container
Dim doc As Document
Dim qdf As QueryDef
Dim ff As Integer
Dim lngCount As Long
Dim strPath As String
Dim strFileDoc As String
Dim strFileNumber As String
Dim strFileObjectLog As String
On Error GoTo ExportObjects_Error
strPath = "U:\objects\"
strFileObjectLog = "object.lst"
ff = FreeFile()
strFileNumber = "#" & CStr(ff)
lngCount = 0
Open strPath & strFileObjectLog For Output As ff
Set dbs = CurrentDb
For Each qdf In dbs.QueryDefs
lngCount = lngCount + 1
strFileDoc = strPath & qdf.Name & ".sql"
Debug.Print lngCount, strFileDoc
SaveAsText acQuery, qdf.Name, strFileDoc '& qdf.Name & ".sql"
Print #ff, acQuery & Chr$(9) & qdf.Name & Chr$(9) & qdf.Name & ".sql"
Next qdf
End Function
I want to export to text the SQL version of all queries in a 2010 mdb.
This code runs in 2003. VBA is not my strength.
Can anyone give me pointers on how to adapt it to 2010?
The first error message is on this line:
Dim dbs As Database ... "User-defined type not defined"
Thanks in advance for any help.
Public Function ExportObjects()
Dim dbs As Database
Dim ctr As Container
Dim doc As Document
Dim qdf As QueryDef
Dim ff As Integer
Dim lngCount As Long
Dim strPath As String
Dim strFileDoc As String
Dim strFileNumber As String
Dim strFileObjectLog As String
On Error GoTo ExportObjects_Error
strPath = "U:\objects\"
strFileObjectLog = "object.lst"
ff = FreeFile()
strFileNumber = "#" & CStr(ff)
lngCount = 0
Open strPath & strFileObjectLog For Output As ff
Set dbs = CurrentDb
For Each qdf In dbs.QueryDefs
lngCount = lngCount + 1
strFileDoc = strPath & qdf.Name & ".sql"
Debug.Print lngCount, strFileDoc
SaveAsText acQuery, qdf.Name, strFileDoc '& qdf.Name & ".sql"
Print #ff, acQuery & Chr$(9) & qdf.Name & Chr$(9) & qdf.Name & ".sql"
Next qdf
End Function