Connecting Tech Pros Worldwide Forums | Help | Site Map

Can you export all queries at once in Access 97 or 2002?

bbcrock@gmail.com
Guest
 
Posts: n/a
#1: Nov 13 '05
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.

I can upgrade the access app to Access 2002, but don't have a 2003
license.

Please let me know if this is possible, because if not, I will stop
searching for a solution.

thanks in advance for any help!

Don


Tim Marshall
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Can you export all queries at once in Access 97 or 2002?


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
Closed Thread


Similar Microsoft Access / VBA bytes