Run Query from Form

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

Guest

I've created a parameter query and use a form to enter the criteria and a command button which runs the query and opens a datasheet containing the results. It works fine the first time I run a query, but if I close the datasheet window, then clear all the fields on the form, enter new criteria and hit the button to run the query based on the new info, it will not return any results. I have to close the form and reopen it to get the query to run. What can I do to make this form work without having to close the form and reopen it each time I want to run a new query?

Code for my commmand button is:
Private Sub cmdSearch_Click()
DoCmd.OpenQuery "qrySearchOrders", acViewNormal, acEdit

End Sub

Thanks,
Lisa
 
Hi,

What happens if you just close the datasheet window and
open it again without clearing the contents of the form
first? Do you get the same results as the first time you
opened it or do you get no results? What is the code for
your query? Do you have some kind of counter in it?
Another thing: There is a property of your form that is
called 'Cycle', change this to 'Current Record', becuase
if you have your Tab order messed up, your query will not
always return the results based on the information on the
form.

Hope that will help.

Simson Grobler
-----Original Message-----
I've created a parameter query and use a form to enter
the criteria and a command button which runs the query and
opens a datasheet containing the results. It works fine
the first time I run a query, but if I close the datasheet
window, then clear all the fields on the form, enter new
criteria and hit the button to run the query based on the
new info, it will not return any results. I have to close
the form and reopen it to get the query to run. What can I
do to make this form work without having to close the form
and reopen it each time I want to run a new query?
 
Back
Top