Use a combo box to choose from a list of queries

  • Thread starter Thread starter oyster
  • Start date Start date
O

oyster

After no replies to my first post on 26 March, I am reposting to try to make
question clearer.

I would like to a Combo box on a form to display a list of Query names so
that when a name is chosen the query runs to filter the records that are
displayed.
I am sure there must be examples that one of your experts can point me to?
Thanks!
 
You can display a list of the queries in the current database with:
SELECT MSysObjects.Name
FROM MSysObjects
WHERE ((MSysObjects.Type = 5)
AND (MSysObjects.Name Not Like "~*"))
ORDER BY MSysObjects.Name;

As far as using a query to filter a particular name, I'm not sure how you
will do that.
 
In the combo box, set:

Name = cboQueries
ControlSource = blank (no value)
Row Source Type = Value List
Row Source = a list of query names, seperated with semicolons. For
example: qryThis;qryThat;qryOther

Create the Click or DbClick event for the combo box (depending on
whether you want the user to click it once, or double-click it. I would
go for double click.)

Put the following statement inside that event:

DoCmd.openquery me![cboQueries]


That should do it.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
Back
Top