As an aside avoid using spaces and other special characters in object and control names, limit your self to alpha and numeric characters and the underscore.
Thanks for the quick reply. I didn't write my question well enough. If I have a select statement, how do I go about creating a query that can be selected from the query object list?
If I've understood you correctly; First double click on the "Create Query in Design View" Icon at the top of the list, Close the Table selector Dialogue box. Now Right Click on the design grid header bar and select SQL View from the list, paste your SQL into the window and save your query.
Thanks, we're getting a closer. If within the vba code behind a form, I have created a select statement based on selections the user has made on the form. I'd like to have VBA that would create a query based on the select statment. I'd like for this query to be displayed on the query list.
So if the user is dynamically creating a query based on the selections they have made in a form, why does that query need to be saved and available from the Query Object window
I then need to export the query results to an excel file. I have found similar code that will edit a query already in existance, I'd like to just create the query. Here's what I've found:
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("testgreg")