Rules for entering search values (ADP)

Microsoft Office Access 2003

The following guidelines apply when you enter text values in search conditions:

  • Quotation marks    Enclose text values in single quotation marks, as in this example for a last name:
    'Smith'
    						

    If you are entering a search condition in the Grid pane, you can simply type the text value and the Query Designer will automatically put single quotation marks around it.

    Note   In Microsoft SQL Server, terms in single quotation marks are interpreted as literal values, whereas terms in double quotation marks are interpreted as database objects such as column or table references. Therefore, even though the Query Designer can accept terms in double quotation marks, it might interpret them differently than you expect.

  • Embedding apostrophes    If the data you are searching for contains a single quotation mark (an apostrophe), you can enter two single quotation marks to indicate that you mean the single quotation mark as a literal value and not a delimiter. For example, the following condition searches for the value "Swann’s Way":
    ='Swann''s Way'
    						
  • Length limits    Do not exceed the maximum length of the SQL statement for your database when entering long strings.
  • Case-sensitivity    Follow the case-sensitivity rules for the database you are using. The database you are using determines whether text searches are case sensitive. Depending on how SQL Server was installed, some databases interpret the operator "=" to mean an exact case-sensitive match, but others will allow matches on any combination of uppercase and lowercase characters. For more information on case-sensitivity, see the SQL Server documentation.

    If you are unsure about whether the database uses a case-sensitive search, you can use the UPPER or LOWER functions in the search condition to convert the case of the search data, as illustrated in the following example:

    WHERE UPPER(lname) = 'SMITH'
    						

ShowSearching on numeric values

The following guidelines apply when you enter numeric values in search conditions:

  • Quotation marks    Do not enclose numbers in quotation marks.
  • Non-numeric characters    Do not include non-numeric characters except the decimal separator (as defined in the Regional Settings dialog box of Windows Control Panel) and negative sign (-). Do not include digit grouping symbols (such as a comma between thousands) or currency symbols.
  • Decimal marks    If you are entering whole numbers, you can include a decimal mark, whether the value you are searching for is an integer or a real number.
  • Scientific notation    You can enter very large or very small numbers using scientific notation, as in this example:
    > 1.23456e-9
    						

ShowSearching on dates

The format you use to enter dates depends on the database you are using and in what pane of the Query Designer you are entering the date. The Query Designer can work with the following date formats:

  • Locale-specific    The format specified for dates in the Windows Regional Settings Properties dialog box.
  • Database-specific    Any format understood by the database.
  • ANSI standard date    A format that uses braces, the marker ‘d’ to designate the date, and a date string, as in the following example:
    { d '1990-12-31' }
    						
  • ANSI standard datetime    Similar to ANSI-standard date, but uses ‘ts’ instead of ‘d’ and adds hours, minutes, and seconds to the date (using a 24-hour clock), as in this example for December 31, 1990:
    { ts '1990-12-31 00:00:00' }
    						

    In general, the ANSI standard date format is used with databases that represent dates using a true date data type. In contrast, the datetime format is used with databases that support a datetime data type.

The following table summarizes the date format that you can use in different panes of the Query Designer.

Pane or view Date format
Grid Locale-specific
Database-specific
ANSI standard

Dates entered in the Grid pane are converted to a database-compatible format in the SQL pane.

SQL Database-specific
ANSI standard

Dates entered into the SQL pane are converted to the locale-specific format in the Grid pane.

Datasheet Locale-specific

ShowSearching on logical values

A value of False is stored as zero (0). A value of True is stored as 1. The following guidelines apply when you enter logical values in search conditions:

  • To search for a value of False, use a zero, as in the following example:
    SELECT * FROM authors
    WHERE contract = 0
    						
  • If you are not sure what format to use when searching for a True value, try using 1, as in the following example:
    SELECT * FROM authors
    WHERE contract = 1
    						
  • Alternatively, you can broaden the scope of the search by searching for any non-zero value, as in the following example:
    SELECT * FROM authors
    WHERE contract <> 0