Building a query in Code

  • Thread starter Thread starter Shane
  • Start date Start date
S

Shane

There may be an easier way to do this but this what I'm
trying to do.

I have a select query that gives me the Purchase order
Id's that a product has been assigned to by clicking on
that product in a list box.

How do I use those ID's for criteria in another query. So
ican vie those records in My purchase Order form.

I know how to change the recordsource once I figure out
how to build the query.
 
-----Original Message-----
There may be an easier way to do this but this what I'm
trying to do.

I have a select query that gives me the Purchase order
Id's that a product has been assigned to by clicking on
that product in a list box.

How do I use those ID's for criteria in another query. So
ican vie those records in My purchase Order form.

Shane, here's what you need to do in each query:

*it's a lot easier to do this if you have the form open in
Form View before you add criteria to the query

* include the field that you want to make equal to the
form's list box selection.

* Then in the Criteria section for that field, click the
Expression Builder button from your toolbar (it's the one
that looks like someone waving a magic wand). Then in the
popup box click Forms, then Loaded Forms, then highlight
the appropriate form name.

* A list of that form's controls appears in the window to
the right. Doubleclick the name of the listbox you want to
link up to.

AFter you do that you should see something like the
following in the Expression window:

=Forms![MyFormName]![MyListBoxName]

Once you see that, click OK. You just told the query to
use the value of that list box as a criterion for the
field in your query.

HTH,
 
Back
Top