Microsoft Office Tutorials and References
In Depth Information
Writing Expressions in Access
Zooming in on expressions
The tiny space provided in the Field row
of the QBE grid doesn’t exactly make typing
lengthy expressions easy. In fact, the text may
be so small that you have difficulty seeing even
when you’re typing a short expression.
To see what you’re typing, press Shift+F2 while
the cursor is in the calculated field, or
rightclick the calculated field and choose the Zoom
option from the contextual menu. The Zoom
dialog box opens, showing what you’ve already
typed in the field (if anything). You can use all
the standard Windows text-editing keys and
techniques to type your expression. Press the
End key to move the cursor quickly to the end
of the expression, for example.
To make the text easier to read, click the Font
button. In the Font dialog box that opens,
choose a larger font size and then click OK to
accept the change. Type your expression and
then click OK in the Zoom dialog box to copy
the expression into your calculated field in the
QBE grid.
Your query can contain any number of calculated fields; you’re not limited
to having just one or two. The big trick, of course, is knowing how to write
the expression. When you write expressions, the possibilities are almost
endless, although some basic tools and rules exist that help you create any
expression, as we discuss next.
Writing Expressions in Access
An expression tells Access how to perform some calculation. An expression
can contain operators, field names, literal text, or all of those — and can
also use any of the Access built-in functions. Built-in functions can be
mindboggling, but if you take them one step at a time, you’ll soon create them
like a pro.
Literal text, in Access jargon, means text that isn’t the name of some field
or other object. Whereas LastName may be the name of a field in a table,
Smith, Jones, and 123 Oak Tree Lane are all examples of literal text.
Always put your literal text in quotes (“Smith”). For a classic example of
how to use literals, flip ahead in this chapter to the “Using literal dates and
times in expressions” section.
Using operators in expressions
An operator is a character that operates on data. Table 2-1 presents some
of the most commonly used operators, listed in order of precedence — the
order in which Access performs the calculations when an expression
contains two or more operators.
Search JabSto ::




Custom Search