totn Access Functions

MS Access: Abs Function

This MSAccess tutorial explains how to use the Access Abs function with syntax and examples.

Description

The Microsoft Access Abs function returns the absolute value of a number.

Syntax

The syntax for the Abs function in MS Access is:

Abs ( number )

Parameters or Arguments

number
A numeric value.

Returns

The Abs function returns a numeric value.

Applies To

The Abs function can be used in the following versions of Microsoft Access:

  • Access 2019, Access 2016, Access 2013, Access 2010, Access 2007, Access 2003, Access XP, Access 2000

Example

Let's look at how to use the Abs function in MS Access:

Abs (-210.67)
Result: 210.67

Abs (-2.9)
Result: 2.9

Abs (-3)
Result: 3

Example in VBA Code

The Abs function can be used in VBA code in Microsoft Access.

For example:

Dim LNumber As Double

LNumber = Abs (-210.6)

In this example, the variable called LNumber would now contain the value of 210.6.

Example in SQL/Queries

You can also use the Abs function in a query in Microsoft Access.

For example:

Microsoft Access

In this query, we have used the Abs function as follows:

Expr1: Abs([Discount])

This query will return the absolute value of the Discount field and display the results in a column called Expr1. You can replace Expr1 with a column name that is more meaningful.

For example:

AbsValue: Abs([Discount])

The results would now be displayed in a column called AbsValue.