pass Where to query from form

H

homer

Hi,
I want to find a way to pass a Where clause to an pre-built query either
from form or from code module in Access 97.
Because the select statement is pretty lengthy and involves many joins, I
want to stay away from pasting the whole statement. Instead, I saved it in a
query.
I looked under OpenQuery, QueryDef, and RunSQL, but none of them meets my
need.

OpenQuery: I did not find a way to pass the where clause to the method.
RunSQL: I did not find a way to bring in existing query sql.
QueryDef seems come most close to what I need. The Parameter will take my
where clause, and the name property will bring in the pre-built query.

Am I on the right track? Can somebody show me an example of querydef, name,
parameter work together?

Thanks!
 
J

Jerry Whittle

In the criteria of the query reference the value in a form's text box like so:

=[Forms]![FormName]![TextBoxName]
 
H

homer

Are you talking about QueryDef or OpenQuery? I cannot assign the text value
to the criteria in the design time of the query, because the query will be
called from multiple places.

Jerry Whittle said:
In the criteria of the query reference the value in a form's text box like so:

=[Forms]![FormName]![TextBoxName]
--
Jerry Whittle
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


homer said:
Hi,
I want to find a way to pass a Where clause to an pre-built query either
from form or from code module in Access 97.
Because the select statement is pretty lengthy and involves many joins, I
want to stay away from pasting the whole statement. Instead, I saved it in a
query.
I looked under OpenQuery, QueryDef, and RunSQL, but none of them meets my
need.

OpenQuery: I did not find a way to pass the where clause to the method.
RunSQL: I did not find a way to bring in existing query sql.
QueryDef seems come most close to what I need. The Parameter will take my
where clause, and the name property will bring in the pre-built query.

Am I on the right track? Can somebody show me an example of querydef, name,
parameter work together?

Thanks!
 

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