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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a field in a table as criteria for a query

Status
Not open for further replies.

rickyoswald

Programmer
Jun 12, 2004
59
0
0
GB
I have a query set up that needs to get a criteria value from a field in another table. So far I have tried writing the criteria as:

=
![Field]

The query asks for the parameter so it's not reading the value in the field. I really have no idea how to set that up, is there a way of writing the criteria to reference the value in the field in the table. The table I'm getting the value from is not the table the query is based on.
 


If I'm reading your question right and if the table with the criteria contains one row you can perform a join on the criteria table:

SELECT fld1, fld2, ...
from table1
right join table2 on table1.fld1 = table2.fld2



Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
The table with the criteria contains just one row and one field. I need to use the value in that field as the criteria in my query.
 


The RIGHT JOIN (INNER JOIN in Access) will return only the rows where both fields are equal. Thus, you will be "using" the content of the single row, single column table as your criteria.


Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Thanks again Mark. My friend used my account to make this post, he has fixed the problem but (unfortunately) says he dosen't know what your talking about! Don't worry, I think it's just him ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top