Application.BuildCriteria (Access)

The BuildCriteria method returns a parsed criteria string as it would appear in the query design grid, in Filter By Form or Server Filter By Form mode. For example, you may want to set a form's Filter or ServerFilter property based on varying criteria from the user. You can use the BuildCriteria method to construct the string expression argument for the Filter or ServerFilter property.

The BuildCriteria method enables you to easily construct criteria for a filter based on user input. It parses the expression argument in the same way that the expression would be parsed had it been entered in the query design grid, in Filter By Form or Server Filter By Form mode. For example, a user creating a query on an Orders table might restrict the result set to orders placed after January 1, 1995, by setting criteria on an OrderDate field. The user might enter an expression such as the following one in the Criteria row beneath the OrderDate field:

BuildCriteria (Field, FieldType, Expression)


Dim strCriteria As String 
strCriteria = BuildCriteria("OrderDate", dbDate, ">1-1-95")

Arguments

The following arguments are required:

Field (String) - The field for which you wish to define criteria.

FieldType (DAO.DataTypeEnum) - An intrinsic constant denoting the data type of the field. Can be set to one of the DAO DataTypeEnum values.

Expression (String) - A string expression identifying the criteria to be parsed.