tech on the net
Home About Us Feedback Site Map

Microsoft

Access Excel Word

Database

SQL Oracle / PLSQL SQL Server MySQL MariaDB PostgreSQL

Web Development

HTML CSS Color Picker

Language

C Language

More

ASCII Table Linux UNIX Java Clipart Joke of the Moment
Share this page:

MS Access: Val Function

Learn how to use the Access Val function with syntax and examples.

Description

The Microsoft Access Val function accepts a string as input and returns the numbers found in that string.

Syntax

The syntax for the Microsoft Access Val function is:

Val ( string )

Parameters or Arguments

string is a string expression.

Note

The Val function will stop reading the string once it encounters the first non-numeric character. This does not include spaces.

Applies To

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

Example

Val ("10 Main Street") would return 10
Val ("34 10 Main Street") would return 3410
Val ("  34 10 Main Street") would return 3410
Val ("  34 - 10 Main Street") would return 34
Val ("075") would return 75

Example (in VBA Code)

The Val function can be used in VBA code in Microsoft Access. For example:

Dim LNumber As Double

LNumber = Val ("56.2 tables")

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

Example (in SQL/Queries)

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

Microsoft Access