PDA

Click to See Complete Forum and Search --> : DAO Create Query to ADO ?


Dillon
Oct 13th, 1999, 01:52 AM
Hi, heres a question for the ADO gurus.
I'm porting an application from dao to ado. The application is a mail merge utility, that creates a database, which Word 2000 in turn links into to access the contacts list.

With DAO, I have been able to create a specific query thru code, which Word then accesses. The question is, how do I get ADO to create this query? Learning the ADO syntax has already got me all "be-fuddled", so any code examples will be much appreciated.

Summary of what i need to do is: Use ADO to dyamically create a permanent Query on an Access 2000 database, using code. All help and snippets of wisdom appreciated!

Dillon
Oct 13th, 1999, 03:52 AM
:) Here's something strange!!! I'm answering my own question...er...for anyone else who might be interested.Sub ADOCreateQuery()

Dim cat As New ADOX.Catalog
Dim cmd As New ADODB.Command
'Open the catalog cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\nwind.mdb;"
'Create the query
cmd.CommandText = "Select * FROM Categories"
cat.Views.Append "AllCategories", cmd
Set cat = Nothing
End Sub

Found an excellent guied to ADO on Microsoft's website, very detailed and simple explaining the syntax clearly. If anyone wants a copy of this 11 page HTML file, you can email me at dgabriel@ilink.nis.za.
Cheers

Dillon
Oct 14th, 1999, 03:32 AM
Help again!

using the above code generates and saves the query(view) in the access database, but does not expose the query to Access.

Using DAO with the exact same procedure style exposes the Query nicely, so I can use Word to access the Query.

Any ideas on how to get this ADO View to be exposed as a query in Access 2000?