for what they want to see in a row (i.e. column headings)
one way is to use two listboxes. The first to list the queries the user can select, the second is a multiselect listbox with its rowsource set to the name of the query selected in the first listbox and rowsource type set to field list.
you then have code to generate a query on a query, the code basically modifying the select part of the query to only include those fields selected in the second listbox. To display, the easiest way is to assign the modified code to a querydef. then set a subform sourceobject to display the data 'query.newquerydef' which will display as a datasheet
A very simple example - assumes you have a query called repQry - can be a query of anything since the sql will be over written
and reportable queries available are say
Q1
Q2
Q3
rowsource for first listbox
SELECT [Name] FROM msysObjects WHERE [Name] Like 'Q*' AND [Type]=5
after update event for first listbox
Code:
Private Sub lbx1_afterUpdate()
lbx2.Rowsource=LBox1
End Sub
user selects the fields required and clicks a button called btnShow
Code:
Private Sub btnShow_Click()
Dim itm as variant
Dim fStr as string
for each itm in lbx2.itemsselected
fstr=fstr & ", [" & lbx2.itemdata(itm) & "]"
next itm
subformname.sourceobject=""
currentdb.querydefs("repQry").SQL="SELECT" & mid(fstr,2) & " FROM " & lbx1)
subformname.sourceobject="Query.repQry"
End Sub
with regards filtering, that gets more complicated as June suggests, but there are plenty of examples on this and other forums as to how that might be achieved - but will get even more complicated if you start to allow users to mix ANDs and ORs in the criteria or they want to combine different queries