pass Where to query from form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!
 
In the criteria of the query reference the value in a form's text box like so:

=[Forms]![FormName]![TextBoxName]
 
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!
 
Back
Top