Passing a Select Query into a paramter

  • Thread starter Thread starter BGuy
  • Start date Start date
B

BGuy

Hello:

I was wondering if an Access SQL statement can pass a
Select query into a parameter, example:

SET @param1 = (SELECT attr FROM table WHERE condition);

Thanks a million!

BGuy
 
Dear Guy:

The answer depends on whether you're writing form Jet or for MSDE.
However, I'm going to assume you mean Jet, and by parameter you mean
that this is a parameter query.

In that case, what you want done could be done using a subquery. The
value you want might be used to filter, for example:

SELECT * FROM YourTable
WHERE SomeColumn = (SELECT attr FROM table WHERE condition)

In order to work properly, the SELECT attr FROM table WHERE condition
needs to be designed so as to guarantee it will always return exactly
one row. Otherwise you can expect to see an error at runtime.

If the parameter is to be used in some other manner, please describe
it.

Hello:

I was wondering if an Access SQL statement can pass a
Select query into a parameter, example:

SET @param1 = (SELECT attr FROM table WHERE condition);

Thanks a million!

BGuy

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
 
Back
Top