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

Call Queries From Forms 1

Status
Not open for further replies.

Jengo

Programmer
Apr 17, 2000
100
US
How can I call a query from a form and change the criteria of one of the types within the query?
 
Jengo,<br>Depending on whether it's an action query or select, you can use the Execute method of the querydef's SQL property (only for Action queries), or use docmd OpenQuery, &quot;queryname&quot;.<br><br>To change criteria, either use parameters and set them through the querydef.parameters collection, or change the sql itself, by setting the sql property of the querydef obect.<br>--Jim
 
Could you give me an example of what you mean?
 
If you are trying to open a query and you want the criteria to be supplied by a field from your form then first open the query in design view and set the criteria for the field to: <br>forms![yourform]![yourcontrolname]<br><br>Then add a button to the form and set the click event to:<br>docmd.openquery &quot;yourquery&quot;<br><br>The query will open and the criteria will be supplied by the control on the form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top