Create an empty query, for this example will call it MyQuery
Create a button on the form to assign SQL to this Query that include a
filter from a field in the form.
Use the code to change the sql within this query, and
then run it.
Application.CurrentDb.QueryDefs("MyQuery").SQL = "Select * From TableName
Where FieldName = " & Me.[Field Name In the form]
Docmd.OpenQuery "MyQuery"
=======================================
Or create a query with reference to the fields in the form
Select TableName.* From TableName Where FieldName =
Forms![FormName]![FieldName]
And create a button on the form to run the query
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benefit from it.
Good luck
"Cindy" wrote:
> I have a query and I'm wondering is there a way to build a form that runs the
> query and you can change certain conditions on the query through the form?
Select * From TableName Where FieldName = [Please enter value here:]
That will prompt the use with a message to enter a value, and the query will
filter the result by this value
To run the query
Docmd.OpenQuery "QueryName"
In the other field of the query I have a criteria of "K*" but there can be 2
criterias either K or T as the first character. Is there a way to specify
this. Do I use a parameter as well.
Select * From TableName Where FieldName Like "K*" Or FieldName Like "T*"
So, the user can select two letters or if he/she press without entering any
letter, it will display all the records