Hi EveryBody,
I am trying to write the SQL-text of all my queries to a text-file using the following two functions -
The file named for writing above in flName/MyFile variable exists at the relevant path.
Access shows syntax error in the code line put in red above. Any help on this error would be highly appreciable. Please Help.
- P K Joshi
I am trying to write the SQL-text of all my queries to a text-file using the following two functions -
Code:
Sub Query_Print()
'This procedure would write SQL-text of all queries in the current database to a text file
Dim db As Database
Dim tbl As TableDef
Dim qry As QueryDef
Dim i As Integer
Dim qryString As String
Dim x As Long
Dim flName As String
Dim flPath As String
Set db = CurrentDb()
flPath = CurrentProject.Path & "\" & db.Name
flName = flPath & "_QUERIES_SQL-Text.txt"
qryString = ""
x = 1
For Each qry In db.QueryDefs
qryString = qryString & x & ". " & qry.Name
qryString = qryString & ":" & vbCrLf & vbCrLf & qry.SQL & vbCrLf & vbCrLf
x = x + 1
'WriteToATextFile (qryString)
Next qry
[COLOR="Red"]WriteToATextFile (flName, qryString)[/COLOR]
End Sub
Sub WriteToATextFile(MyFile As String, AppendThisString As String)
'set and open file for output
fnum = FreeFile()
Open MyFile For Append As fnum
Print #fnum, AppendThisString
Close #fnum
End Sub
Access shows syntax error in the code line put in red above. Any help on this error would be highly appreciable. Please Help.
- P K Joshi
Last edited: