Automatically change an Access Queries

  • Thread starter Thread starter Kathy
  • Start date Start date
K

Kathy

Is there a way in code to automatically change the criteria in a
query? I want to make the change based on a value selected in a drop
down box.

Thanks,
 
You can use the QueryDef Object (DAO Library needed in the References) to
modify the SQL String of the Query. You can also use ADO Catalog.
 
Is there a way in code to automatically change the criteria in a
query? I want to make the change based on a value selected in a drop
down box.

Thanks,

The simplest way is to directly reference the form and the combo box
in the Criteria cell of the query grid: just type

=[Forms]![NameOfYourForm]![NameOfYourComboBox]

using your own form and combo box names, of course. The form must be
open for this to work; but you can put a command button on the form to
open a Report or another Form in which to display the query data.
 
Back
Top