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

Cancel the "Run Query" Command

Status
Not open for further replies.

angiew

Technical User
Jun 22, 2000
37
0
0
US
I have a form that is bound to a query.&nbsp;&nbsp;The form allows for filtering the results of the query.&nbsp;&nbsp;Currently, the action of opening the form cause the query to run.&nbsp;&nbsp;I would like to cancel that if possible and only run the query after the filter criteria has been specified.&nbsp;&nbsp;Is this possible?&nbsp;&nbsp;I can't find any code that relates to this action of running the query when the form is opened.&nbsp;&nbsp;The only code underlying the form is for the three buttons that are on the form.&nbsp;&nbsp;These buttons are &quot;Edit Filter&quot;, &quot;Preview Report&quot;, and &quot;Print Report&quot;.&nbsp;&nbsp;I don not have an OnOpen event for the form, either.&nbsp;&nbsp;Thanks!<br><br>Angie<br>
 
Why do you want to run the query? What is the criteria you are looking for?&nbsp;&nbsp;Because you could run the query on an if statement.<br>If me.Name = something then<br>'do nothing<br>else<br>docmd.OpenQuery&nbsp;&nbsp;&quot;qryappend&quot; or whatever your query name is<br>
 
You have to make sure the criteria are set though to variables first sorry I forgot<br>
 
The query is used to allow managers to filter our sales information based on various criteria that they choose from combo boxes.&nbsp;&nbsp;These combo boxes are on the form.&nbsp;&nbsp;What I am trying to do is also include two text boxes so they can filter by sales date, for example, all sales from May to August of 1999.&nbsp;&nbsp;I think I know how to do this, but currently the query runs when the form is opened, resulting in a blank form because the dates have not been filled in.&nbsp;&nbsp;It is necessary to have the managers only use the form for entering/selecting the filter criteria.&nbsp;&nbsp;Hope this helps!<br><br>angie<br>
 
Then have it run in the BeforeUpdate or AfterUpdate in the code module for the form.<br><br>Form Name BeforeUpdate()&nbsp;&nbsp;&lt;-----This is in vb code<br><br>
 
First try it in a message box to see if that is when you want it to run<br>MsgBox &quot;BeforeUpdate&quot;<br>in before update it will show this before it updates the record!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top