how pass parameter to a query?

G

Guest

I need to run a query and supply it with an ID (autonum key) which will vary
each time the query is run and may come from any number of forms. Is there
any way to create a query which takes a parameter? My Access book (with 1612
pages) does not mention it.
Thanks in advance.
 
J

Jeff Boyce

Instead of trying to get a query to accept a parameter from "any number of
forms", if you actually need this much flexibility, consider creating a
procedure that dynamically builds a SQL statement (i.e., a query!), based on
the form providing the ID. Then run the SQL.

(and if you don't mind me asking, why would you be selecting an ID from "any
number of forms"?)

Good luck

Jeff Boyce
<Access MVP>
 
G

Guest

I was told that pre-written queries are more efficient, thats why I was
hoping there was a mechanism to pass a parameter to a query. I guess I will
have to code the SQL in a function.
 
J

Jeff Boyce

That may have been an issue in earlier versions of Access. More recently,
from what I understand, SQL statements are roughly as efficient.

Is the speed of this query a significant factor? Are there other "speed
ups" you have tried (e.g., indexing the underlying select and join fields)?

And I am still curious about the multiple forms!

Jeff Boyce
<Access MVP>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top