drop down list w/ Constraint

  • Thread starter Thread starter Meilu
  • Start date Start date
M

Meilu

Hi All,

I was wondering... is it possible to create a drop down
list based on a qry that requires a parameter?

Example:

I have 2 fields: City & Destination
I also have a qry that returns City w/ cooresponding
Destination.

In the form/table I want to be able to choose Destination
from a look-up list based upon the City chosen.

I tried achieving my goal in the Form first.
In the Data Source of Destination I tried using:
Select Destination
From Qry
Where Qry.City = City;

Then I tried straight from the table by Setting the
Destination field to be a Combo box. And setting the Row
Source as
Select Qry.Destination
From Qry
Where Qry.City = City;

But both approaches don't work. Because the value
of "City" isn't changing w/ each record. I was wondering
if anyone knows what I'm doing wrong?

-Meilu
 
Simple Answer...Yes

If you already have the field on your form, go to the Row
source field in the properties sheet for the field. Click
the "...". The rowsource type needs to be Table/Query.
Clicking the ... in the rowsource should bring up the
query builder. Create your query there and close it out
when your done. Don't save it as you would normally by the
save button on the tool bar or the save menu choice as
this will create a query in the queries tab of the
database. If you just close the qbe window using the x in
the upper right corner, you will be presented with a
message box that will say something about saving the
changes to the SQL Statement and Update the property.
Choose yes here.

That's all there is to it. You can also create a query,
but this is a little cleaner and limits your list of stand
alone queries.

I hope this helps!
 
Back
Top