I'm new to ADO, and I'm presently trying to understand how to create queries using ADO on Access 2000. I've got the following code written:
This creates a query (or is it called a View?) called "test123". Now that I have this, I would like to display the data in a table form, just like when I execute a query I make with the query wizard. How do I do this?
I've tried
doCmd.OpenQuery "test123"
but Access responds with the error message
"database can't find the object 'test123'"
After I display the table, my next step will be to export the data into a format that I can read with MS Excel. An example of how to display the query and output the data to a MS Excel file would be greatly appreciated!
Code:
Dim strSQL As String
Dim cmd As ADODB.Command
Dim cat As ADOX.Catalog
strSQL = "SELECT ID FROM tbl_WorkOrder_Entry WHERE [Model #] = ""Widget1"""
Set cat = New ADOX.Catalog
cat.ActiveConnection = CurrentProject.Connection
Set cmd = New ADODB.Command
cmd.CommandText = strSQL
cat.Views.Append "test123", cmd
cat.Views.Refresh
Set cat = Nothing
Set cmd = Nothing
This creates a query (or is it called a View?) called "test123". Now that I have this, I would like to display the data in a table form, just like when I execute a query I make with the query wizard. How do I do this?
I've tried
doCmd.OpenQuery "test123"
but Access responds with the error message
"database can't find the object 'test123'"
After I display the table, my next step will be to export the data into a format that I can read with MS Excel. An example of how to display the query and output the data to a MS Excel file would be greatly appreciated!