23
BUILDING CRITERIA EXPRESSIONS

Building Criteria Expressions

Embed Size (px)

DESCRIPTION

This is a document which will help you in creating criteria expressions in Microsoft access which is a special feature of Microsoft access that will help you sort out all the required results.

Citation preview

Building criteria expressions

Building criteria expressionsintroductionExpressions in Microsoft access can be considered similar to formulae in excel.Expression are a combination of operands, operators, functions and values.Expressions can be used with tables, queries, forms, reports and macros.In access, expressions are used to obtain calculated values, provide criteria.Access uses a powerful user interactive tool called as Expression Builder to create expressions.Using operands in criteria expressionsQuery criteria are the most important part of any query as they permit users to select only the desired records from an existing table.An operand is a value on which a calculation is performed.Operands can be Literals, Identifiers or Functions.LiteralsIt is a value that is not addressed by a name.It can be typed directly into the criteria expressions.In access, literal can be of type number, text, date or Boolean value.Ex. [Date]> #1/1/2011#Marks1+marks2 etc.identifiersIdentifiers are variables.They represent field name, table name or control name. They are an important part of expression builder because they specify the column to which an expression represents.They are always represented in [] brackets.Ex. [basic salary] + [tax]functionsThey provide special operations.These are built in expressions that take an input, perform necessary calculations on it and return the output.The input accepted by the function is called as argument; a function may have more than one argument.Access provides us different functions to work with different type of data, such as text functions, date and time functions, numeric functions, and mathematical functions.Ex. Length (MS Access) will return 9Using operators in criteria expressionsOperators make the expression complete.They are special symbols such as +, -, used with operands to perform calculations.Every operator has a specific meaning and a symbol.Operators help in creating expressions with the combination of identifiers and values.Every operator is executed according to a priority.

Operators continue.. Different typesCOMPARISION OPERATORSARITHMETIC OPERATORSMISCELLANEOUS OPERATORSCOMPOUND CRITERIA & LOGICAL OPERATORSCOMPARISION OPERATORsThey are called as relational operators.They define relation between two identifiers or two values by comparing them.These operators can be used with numeric or date data type.

OPERATORNAME>Greater than=Greater than equal to 500000, it will return customers from California who have credit limit greater than 500000 OR criteriaIn OR, compound criteria will return results if either of the criterion specified is true.Ex. If we add criteria to the query from the customer table as:[State] = CA OR [Credit Limit] > 500000, it will return all customers either from California or who have credit limit greater than 500000

Using the built in functionsMathematicalDate/timeFinancialSql aggregateText

Text functionsNAMEEXPLANATIONEXAMPLELEFT ()Return characters from left of stringLeft (Access,3) will return ACCRIGHT ()Return characters from right of stringRight (Access,3) will return essMID ()Return characters at specified position of stringMid (Access,2,3) will return cceLEN ()Return length of stringLen (Access) will return 6LCASE ()Convert text to lower caseLcase(ACCESS) will return access UCASE ()Convert text to upper caseUcase (access) will return ACCESSINSTR ()Return the position of first occurrence of a string in another stringInstr (Operations,ra) will return 4TRIM ()Remove space in a stringTrim ( ACC ESS ) will return ACC ESSREPLACE ()Replace the stringReplace (Account Transaction,Account,Daily) returns Daily TransactionsSTRCOMP ()Compare two string. If equal 0 and 1 if first string is greater and -1 if second string is greaterSTRREVERSE ()Reverse the stringDate and time functions

Math functions

Financial functions

Financial functions