

If no criteria are specified in the query form, all records that are not null are returned. This criteria statement returns all the records that match the criteria. Because the asterisk is a hard-coded criteria value (for example, Like "*"), records with null values are returned. Note that the asterisk (*) is considered a parameter because it is part of a larger Like expression. If the criteria are null, all the records are returned. This criteria statement returns both records that match the criteria and records that are null. Like Forms! FormName! ControlName& "*" Or Is Null If you omit a Start Date value on the form, however, the query returns all records, regardless of the End Date value. Records whose start and end dates fall between the values that you specify on the query form are returned. You can use this criteria statement to query a date field by using Start Date and End Date text boxes on the query form. For example, if you enter "Jo" in a field by using this criteria statement, the query returns every record in the field that begins with "Jo." This includes Johnson, Jones, Johanna, and so on.īetween Forms! FormName!StartDate And Forms! FormName!EndDate Or _ This criteria statement is the same as the QBF sample above, except that you can query by using a wildcard. Like Forms! FormName! ControlName& "*" Or _ Remove the underscore from the end of the line when you re-create these criteria. In the following sample criteria, an underscore (_) is used as a line-continuation character. You can specify any of the following alternative criteria to return slightly different results. If the criteria value is null, all the records are returned for the specified field. These criteria return all matching records. The sample QBF query in this article implements criteria in the query asįorms! FormName! ControlNameOr Forms! FormName! ControlNameIs Null Each time that you click the Search button, the parameters in the QBF query filter the data based on the search criteria that you specified on the QBF query form. Click Search after each combination: Customer ID Employee ID ResultĪfter you view the result set for each query, close the Datasheet window. Enter the following combinations of criteria. NOTE: When you type the criteria, make sure that you type the entire criteria in a single Criteria field do not split the criteria by placing the 'Or' section on a separate row. On the new form, create two text boxes and one command button that has the following properties.Then, save the form: Text box 1Ĭreate the following new macro, and then save it as QBF_Macro: Action: OpenQueryĬreate the following new query that is based on the Orders table, and then save it as QBF_Query: Field: CustomerIDĬriteria: Forms!! Or Forms!! Is Null To use the QBF technique, follow these steps:Ĭreate a new form that is not based on any table or query, and save it as QBF_Form. When you click a command button on the form, Access runs a query that uses the search criteria from your form.
#Microsoft office price query filter code#
You can specify a city only, or a city and a state, or a ZIP code only, or any other combination.

To select certain records, you can enter any combination of search criteria in the form. A table that has fields for Name, Address, City, State, and ZIP Code can have a QBF form that has corresponding fields. The QBF form resembles a data entry form that has fields that match the fields in a table. You make entries only in the text boxes for which you want to specify search criteria. Each text box represents a field in a table that you want to query. In the QBF technique, you create a form in which you enter query criteria. This technique is called query by form (QBF).
#Microsoft office price query filter how to#
This article shows you how to use a form to specify the criteria for a query. This article applies only to a Microsoft Access database (.accdb and. Requires basic macro, coding, and interoperability skills.
