Criteria to query

  • Thread starter Thread starter Marc
  • Start date Start date
M

Marc

I have query with some Criteria in Columns. If I want to modidy query, I
need to open query with Design view. How I can automate this step with
wizard or something?
 
You can take a look at parameter queries.

You can also take a look at using a form to feed the parameter values to the query.

You can also use VBA to build the entire SQL string.

Check out this article for a detailed discussion.
http://www.fontstuff.com/access/acctut08.htm


A brief quote from an John Vinson (Access MVP) posting on using a form to set
parameter values with a combobox.

You'll need to create a small unbound Form (let's call it frmCriteria) with a
Combo Box control (cboCrit) on it. Use the combo box wizard to select the table
for the selections, and be
sure that the bound field of the combo is the value you want to use as a
criterion. Save this form.

Now use

=[Forms]![frmCriteria]![cboCrit]

as the criterion in your Query.

It's convenient to base a second Form or Report on the resulting query to
display the results; if you put a button on frmCriteria to launch that form or
report, the user can enter the criterion and view the results in one simple operation!

Quoting John Vinson

Keywords: Parameter Queries
 
Marc

That really depends on what you mean by "automate"...

If you are saying that you'd like to run the query and be prompted for the
criteria, you can replace the values you have as criteria with parameter
prompts, something like:

[Enter the date]

Whatever prompt is appropriate for the field, place it between square
brackets. When the query runs, it will prompt with the message for the
criterion.
 
John Spencer said:
You can take a look at parameter queries.

Keywords: Parameter Queries


Hi John,
I founded
http://office.microsoft.com/trainin...ID=RP010969871033&CTT=6&Origin=RP010969851033,
and success enter between [ ] and [ ] parameter query.

But, my question: I want to setup parameter queries so when I enter only one
keyword from the column - that query must display all the rows with this
keyword in that column... At the moment, I setup query with "LIKE
'*keyword*', but I don't want to use for every time Design View and change
this keyword (use parameter query)

please help againg....

Thnx
 
http://support.microsoft.com/kb/304353/EN-US/

How to Create Parameters That Use Wildcards
The following example shows you how to create parameters that use the LIKE
operator and the wildcard symbol (*). 1. Start Microsoft Access 2000, and
then open the sample database Northwind.mdb.
2. On the View menu, click Database Objects, and then click Queries.
3. In the Database window, click the Invoices query, and then click
Design.
4. Type the following line in the Criteria cell for the ProductName
field:
LIKE "*" & [Enter products that contain the phrase] & "*"
5. On the Query menu, click Run. When you are prompted, type sauce,
and then click OK to view the results of the query. Note that the query
returns only those records whose product name contains the word "sauce."


6. Close the query without saving it.




That's it! Step 4 is that I want!
 
Like '*' & [Find what value] & '*'
John Spencer said:
You can take a look at parameter queries.

Keywords: Parameter Queries

Hi John,
I founded
http://office.microsoft.com/trainin...ID=RP010969871033&CTT=6&Origin=RP010969851033,
and success enter between [ ] and [ ] parameter query.

But, my question: I want to setup parameter queries so when I enter only one
keyword from the column - that query must display all the rows with this
keyword in that column... At the moment, I setup query with "LIKE
'*keyword*', but I don't want to use for every time Design View and change
this keyword (use parameter query)

please help againg....

Thnx
 
Back
Top