This MSAccess tutorial explains how to use the Access Val function with syntax and examples.
The Microsoft Access Val function accepts a string as input and returns the numbers found in that string.
The syntax for the Val function in MS Access is:
Val ( string )
Note: The Val function will stop reading the string once it encounters the first non-numeric character. This does not include spaces.
The Val function can be used in the following versions of Microsoft Access:
Let's look at how to use the Val function in MS Access:
Val ("10 Main Street") Result: 10 Val ("34 10 Main Street") Result: 3410 Val (" 34 10 Main Street") Result: 3410 Val (" 34 - 10 Main Street") Result: 34 Val ("075") Result: 75
The Val function can be used in VBA code in Microsoft Access.
Dim LNumber As Double LNumber = Val ("56.2 tables")
In this example, the variable called LNumber would now contain the value of 56.2.
You can also use the Val function in a query in Microsoft Access.
In this query, we have used the Val function as follows:
This query will return the starting numeric values from the Description field and display the results in a column called Expr1. You can replace Expr1 with a column name that is more meaningful.
The results would now be displayed in a column called NumericValue.
(scroll to see more)