MS Access: Sqr Function
This MSAccess tutorial explains how to use the Access Sqr function with syntax and examples.
Description
The Microsoft Access Sqr function returns returns the square root of a number.
Syntax
The syntax for the Sqr function in MS Access is:
Sqr ( number )
Parameters or Arguments
- number
- The the number to calculate the square root for.
Note
- If a negative number is entered in the number parameter, the Sqr function will raise an error.
Applies To
The Sqr 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 Sqr function in MS Access:
Sqr(49) Result: 7 Sqr(144) Result: 12 Sqr(200) Result: 14.142135623731
Example in VBA Code
The Sqr function can be used in VBA code in Microsoft Access.
For example:
Dim LResult As Double LResult = Sqr(36)
In this example, the variable called LResult would now contain the value of 6.
Example in SQL/Queries
You can also use the Sqr function in a query in Microsoft Access.
For example:
In this query, we have used the Sqr function as follows:
Expr1: Sqr([Discount])
This query will return the square root 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:
SquareRoot: Sqr([Discount])
The results would now be displayed in a column called SquareRoot.
Advertisements