'generic' subform that can display any query?

  • Thread starter Thread starter Tim Rogers
  • Start date Start date
T

Tim Rogers

I am trying to produce a form that has a combo box that lists all
queries. The user can select a query from this combo box and click a
button to 'execute' it. What I want to happen when it is 'executed'
is I want to set a subform's (of this form) recordsource to this
query. I can currently do this, but the subform was created (by a
wizard) based on a particular query. When I update the subform's
form's RecordSource property the data changes, but the column
'headers' do not. So, if I have columns in the new query that happen
to match the columns in the query the subform was based on I get real
data. I get #Name? in the other columns.

The reason I am trying to do this is so I can allow users, from a form
I have created, to run any query they want (that has an 'email' column
in the query - that's a pre-req) and have it display in a subform in a
'datasheet' view. Then, they can sort and filter even further on that
query result. Once they have the data that they want, they'll click
another button and I will want to iterate through the records that are
'visible' (as a result of their sorting/filtering) in the subform and
pull out all the values for the e-mail column. The ultimate goal of
this exercise is to get a list of e-mail addresses from any number of
queries they choose. Then, I've got to do several tasks with those
e-mail addresses (which aren't relevant to this discussion).

1) Is it possible to create a 'generic' subform that I can put the
results of any query into?

2) If I access the subform's data via RecordsetClone, will that data
be the data the user sees as a result of sorting/filtering with the
datasheet or will it be the entire result of the query?

Thanks,

Tim Rogers
 
On my website (see sig below) is a small sample database called
"CrosstabReport.mdb" Which might give you some help.

Now why am I recommending this? You don't have a crosstab and your not
using a report. However, the issues are much the same. It is difficult to
use a crosstab query as the record source for a report because the fields
can change each time.

In the sample, I have the report based on a generic query and then
programmically modify the query to alias the fieldnames the generic names
the report is expecting. I suspect something similar will work for what you
want to do.
 
Back
Top