Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting a variable = Query

Status
Not open for further replies.

tmccork

Technical User
Jul 12, 2002
13
US
How do I get a variable to = the value of a query, then from that variable run another query to display a list of all records with that have that value.

I am not sure where to start, any ideas will help.
Thanks
 
Will the 1st query always return just one value (is it a Select Top 1 query)? Or may there be more than one value?
 
This will be used in a double click search box. The goal is to double click on one record, from that record have it run a query to display an associated item from a seperate table. Then find all records that have the same property.

eg: Double click on a [Wire ID] from a list box on a form.
(Query1) finds the [Room #] that the selected [Wire ID] is located in, and displays it in a window on the same form.
(Query2) then finds all of the [Wire ID]s located in the [Room #] from (query1) and displays them in a window on the same form.

We are trying to figure out the code for getting (Query2) to reference the output [Room #] from (Query1)

I hope that this makes sence.
Thank you
Terry
 
What do you think of this idea?:

Give your users a drop-down box that has 2 columns: [Room #] and [Wire ID]. The bound column being the [Room #], but the records being sorted by [Wire ID]. You could even hide the [Room #] column from them.

The Row Source of your list box (where you would get a list of all wires for the room in question) would be something like this, then:

Select [Wire ID] from [myTable]
Where [Room #] = Forms![myForm].[myCombo].Value
Order by [Wire ID]

When you change the combo, do a requery on the list box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top