bbcrock@gmail.com wrote:[color=blue]
> I have an employee who created 70 queries in MS Access 97. I want to
> export all these queries into plain-text SQL statements at one time. A
> coworker in charge of Access said the only way is to cut and paste each
> query by hand. That is going to be a painful process and I'd rather do
> this automatically.[/color]
Try this.
Click on the modules tab
click "new" to create a new module. Save the module as something or other.
Paste the following code into it:
'***COde start***
Function fGetAllQuerySql() As String
Dim dbs As dao.Database
Dim q1 As dao.QueryDef
Dim str1 As String
Set dbs = Access.CurrentDb
str1 = ""
For Each q1 In dbs.QueryDefs
If Left(q1.NAME, 3) <> "~sq" Then
If str1 <> "" Then str1 = str1 & vbCrLf & _
"-------------------------------------"
str1 = str1 & vbCrLf & "Query Name: " & q1.NAME
str1 = str1 & vbCrLf & vbCrLf & q1.SQL
End If
Next
fGetAllQuerySql = str1
End Function
'***COde end***
Now, open the debug window by pressing ctrl-G
Type in:
?fGetAllQuerySql
and press enter. You'll get a list of all query names and the SQL
separated by dashed lines.
--
Tim
http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me