Prompt from Query

J

Joe Cilinceon

How would I get a query to prompt me for criteria.

Example:
Between Date1 and Date2
PaymentAmount (currency)
PayMethod (Int)
Tracking (string)

I'm trying to add a query from a button on a form to do a search of a given
payment.
 
J

John Vinson

How would I get a query to prompt me for criteria.

Example:
Between Date1 and Date2
PaymentAmount (currency)
PayMethod (Int)
Tracking (string)

I'm trying to add a query from a button on a form to do a search of a given
payment.

Two ways:

To get a popup box prompting, use the prompt in square brackets on the
Criteria line, e.g.

BETWEEN [Enter start date:] AND [Enter end date:]

or

[Enter payment amount:]

Better - because it's easier of the user - put unbound (no Control
Source) textboxes on your form. Let's say the form is named frmSearch;
put textboxes txtFrom, txtTo and txtAmount; and combo boxes
cboPayMethod and cboTracking (or a textbox txtTracking if the value of
Tracking isn't drawn from a preexisting list of values). In your Query
use

BETWEEN [Forms]![frmSearch]![txtFrom] AND [Forms]![frmSearch]![txtTo]

on the date field;

[Forms]![frmSearch]![cboPayMethod]

on the pay method field, etc.

Also... base a Form (for onscreen viewing) or Report (for printing) on
this query. Your command button should open the form or report
directly; there is no need to "run" the query or show the user the
query datasheet view.

John W. Vinson[MVP]
 
J

Joe Cilinceon

Thanks John, I'll look at the method you suggested also.

John said:
How would I get a query to prompt me for criteria.

Example:
Between Date1 and Date2
PaymentAmount (currency)
PayMethod (Int)
Tracking (string)

I'm trying to add a query from a button on a form to do a search of
a given payment.

Two ways:

To get a popup box prompting, use the prompt in square brackets on the
Criteria line, e.g.

BETWEEN [Enter start date:] AND [Enter end date:]

or

[Enter payment amount:]

Better - because it's easier of the user - put unbound (no Control
Source) textboxes on your form. Let's say the form is named frmSearch;
put textboxes txtFrom, txtTo and txtAmount; and combo boxes
cboPayMethod and cboTracking (or a textbox txtTracking if the value of
Tracking isn't drawn from a preexisting list of values). In your Query
use

BETWEEN [Forms]![frmSearch]![txtFrom] AND [Forms]![frmSearch]![txtTo]

on the date field;

[Forms]![frmSearch]![cboPayMethod]

on the pay method field, etc.

Also... base a Form (for onscreen viewing) or Report (for printing) on
this query. Your command button should open the form or report
directly; there is no need to "run" the query or show the user the
query datasheet view.

John W. Vinson[MVP]
 
Top