MS Access: Str Function
This MSAccess tutorial explains how to use the Access Str function with syntax and examples.
Description
The Microsoft Access Str function returns a string representation of a number.
Syntax
The syntax for the Str function in MS Access is:
Str ( number )
Parameters or Arguments
- number
- The value to convert to a string.
Applies To
The Str 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 Str function in MS Access:
Str (12) Result: " 12" Str (450) Result: " 450"
Example in VBA Code
The Str function can be used in VBA code in Microsoft Access.
For example:
Dim LResult As String LResult = Str (16)
In this example, the variable called LResult would now contain the value " 16".
Example in SQL/Queries
You can also use the Str function in a query in Microsoft Access.
For example:
In this query, we have used the Str function as follows:
Expr1: Str(12)
This query will convert the numeric value of 12 to a string and display the results in a column called Expr1. You can replace Expr1 with a column name that is more meaningful.
For example:
StringValue: Str(12)
The results would now be displayed in a column called StringValue.
Advertisements