I'm trying to figure out if I can modify a generic form I created a long time ago that provides an easy method for users to perform ad hoc queries on tables/queries. You (the programmer) has to set up the appropriate information in a table (the name of the table or query, each column that can be used for criteria and/or sorting and/or grouping or totals for a grouping query, type of data for each column and a combo box if appropriate, etc.). That table is used to populate the drop downs on the ad hoc query builder form. Once the user selects the criteria and how to sort the results, the form builds two queries (originally for an Access back end, now modified to create a pass through query for a SQL Server back end). One returns all of the matching records, the order group by the sort column(s) and totals or counts the appropriate columns. The results are displayed by opening each query, and because they open in a spreadsheet format, the results can easily be copied by the user into Excel.
I'm hoping that I can modify the code created by this ad hoc query form to accomplish the same results with an Access Project. However, Access Project is not linked (in the normal Access sense) to the SQL database. There are no Jet queries or tables. Basically, I'm already creating SQL code that can be executed within SQL Server. The problems is how to get it to run and to display the results in the spreadsheet format.
Anyway, after I dimensioned objRecordSet, your code worked. Thanks. However, I can't set the recordset of the form as equal to objRecordSet. In fact, I get an error message when I try to display the value of a column in the recordset. Perhaps it needs to be a different type of recordset.
At least we're getting closer.
Bob