Professional Documents
Culture Documents
Access: Sum
Function
In Access, the Sum function returns the sum of a set of values in a set of values in a select
query.
Sum ( expression )
The expression argument represents a string expression identifying the field that contains the
numeric data you want to add or an expression that performs a calculation using the data in
that field. Operands in expr can include the name of a table field, a constant, or a function
(not one of the other SQL aggregate functions). The Sum function totals the values in a field.
It ignores records that contain Null fields.
SQL query
In Access, you can use the Sum function in the query design grid, in an SQL statement in
SQL view of the Query window, or in an SQL statement within Visual Basic code. It is used in
conjunction with the Group By clause.
EXAMPLE:
HÀM ASC:
Access: Asc
Function
In Access, the Asc function returns an integer representing the ANSI code corresponding to
the first character in a string.
Asc ( string )
The required string argument is any valid string expression. If the string contains no
characters, a run-time error occurs. If more than one character is entered, the function will
return the value for the first character and ignore all of the characters after the first.
Example
Asc ( "a" ) returns 97
SQL query
You can also use the Asc function in a query.
FROM Orders
HÀM ASB:
Access: Abs
Function
In Access, the Abs funtion returns the absolute value of a number.
Abs( number )
The argument number can be any valid numeric expression. If number contains Null, Null is
returned. The absolute value of a number is its unsigned magnitude. For example, ABS(-1)
and ABS(1) both return 1.
Example
Abs (-1.45) returns 1,45
SQL query
You can also use the Abs function in a query.
FROM EmployeeStatisticsTable
HÀM ATN:
In Access, the Atn function returns a double containing the arctangent of a number.
Atn( number )
The required number argument can be any valid numeric expression. The Atn function takes
the ratio of two sides of a right triangle (number) and returns the corresponding angle in
radians. The ratio is the length of the side opposite the angle divided by the length of the
side adjacent to the angle.
Example
Atn (15) returns 1,50422816301907
MyNumber = Atn(2)
This example uses the Atn function to calculate the arctangent of a
number. Now the MyNumber variable would contain the value 1,10714871779409.
SQL query
You can also use the Atn function in a query.
FROM Orders
HÀM AVG:
Access: Avg
function
In Access, the Avg function calculates the arithmetic mean of a set of values in a select
query.
Avg ( expression )
The expression argument represents a string expression identifying the field that contains
the numeric data you want to average. Operands in expression can include the name of a
table field, a constant, or a function (not one of the other SQL aggregate functions). The
average calculated by Avg is the arithmetic mean (the sum of the values divided by the
number of values). You could use Avg, for example, to calculate average freight cost.The Avg
function doesn't include any Null fields in the calculation.
SQL query
In Access, you can use the Avg function in the query design grid, in an SQL statement in
SQL view of the Query window, or in an SQL statement within Visual Basic code. It is used in
conjunction with the Group By clause.
HÀM
CHOOSE FUNCTION:
Access: Choose
Function
In Access, the Choose function selects and returns a value from a list of arguments based on
a given position.
You can use Choose to look up a value in a list of possibilities. If index is 1, Choose returns
the first choice in the list; if index is 2, it returns the second choice, and so on. The Choose
function returns a Null if index is less than 1 or greater than the number of choices listed.
Example
Choose(1, "Have", "a", "nice", "day") returns "Have"
SQL query
You can also use the Choose function in a query.
HÀM Chr:
Access: Chr
Function
In Access the Chr function returns the character associated with the specified ANSI code.
Chr ( charcode )
The required charcode argument is the NUMBER used to retrieve the character. The
argument charcode is an integer between 0 and 255, inclusive. Applications for Microsoft
Windows use the ANSI character set. ANSI character codes in the range 0 to 31, inclusive,
are the same as the standard, nonprintable ASCII codes. For example, Chr(13) returns a
carriage-return character, and Chr(10) returns a linefeed character. Together they can be
used to force a new line when message strings are formatted with MsgBox or InputBox.
Example
Chr( 65 ) returns "A"
SQL query
You can also use the Chr function in a query.
FROM Orders
HÀM COS:
Access: Cos
Function
In Access, the Cos function returns a double containing the cosine of an angle.
Cos ( number )
The argument number can be any valid numeric expression that expresses an angle in
radians. The Cos function takes an angle and returns the ratio of two sides of a right
triangle. The ratio is the length of the side adjacent to the angle divided by the length of the
hypotenuse.
SQL query
You can also use the Cos function in a query.
FROM Orders
HÀM COUNT:
Access: Count
Function
In Access, the Count function calculates the number of records in a select query.
Count ( expression )
The required expression argument represents a string expression identifying the field that
contains the data you want to count or an expression that performs a calculation using the
data in the field. Operands in expression can include the name of a table field or function
(not other SQL aggregate functions). You can count any kind of data, including text. The
Count function doesn't count records that have Null fields unless expression is the asterisk
(*) wildcard character. If you use an asterisk, Count calculates the total number of records,
including those that contain Null fields.
SQL query
In Access, you can use the Count function in the query design grid, in an SQL statement in
SQL view of the Query window, or in an SQL statement within Visual Basic code. It is used in
conjunction with the Group By clause.
HÀM CurDir:
Access: CurDir
Function
In Access, the CurDir function returns a string containing the full path of the specified drive.
CurDir ( drive )
The optional drive argument is a string expression that specifies an existing drive. If this
parameter is omitted or it is a zero-length string (""), CurDir returns the path for the current
drive.
Example
CurDir () returns "C:\Documents and Settings\UserName\My Documents"
SQL query
You can also use the CurDir function in a query.
CurDir = VBA.CurDir(Drive)
End Function
HÀM DATE:
Examples
Date() returns a value such as '05.05.2005'
VBA Code
Dim MyDate
MyDate = Date
Now the MyDate variable would contain the current system date.
SQL query
You can also use the Date function in a query.
FROM Orders
HÀM DATEADD:
You can use the DateAdd function to add a specified time interval to or subtract a specified
time interval from a date. For example, you can use DateAdd to calculate a date 15 days
from today or a time that is 30 minutes from now.
interval is the interval of time you want to add to date. The following is a list of valid interval
values.
Interval Description
yyyy Year
q Quater
m Month
y Day of year
w Weekday
ww Week
h Hour
n Minute
s Second
number is the number of
intervals you want to add to date. It can be positive (to get dates in the future) or negative
(to get dates in the past).
Examples
DateAdd ('m', 4, #01/22/2004# ) returns 05/22/2004
SQL query
You can also use the DateAdd function in a query.
FROM Orders