Home page
 
 Home 
 ASP 
 PHP 
 SQL 
 HTML 
 JavaScript 
 Search 
 Contact 
 
Search
or browse popular tags
Access Functions
Subscription

Sign up for the free email newsletter for new tips, tutorials and more. Enter your email address below, and then click the button.

Privacy Policy

RSS Twitter

Access: Val Function

Print

In Access, the Val function returns a variant indicating the sign of a number.

The syntax for the Val function is:

Val( string )

The required string argument is any valid string expression. It is a sequence of characters that can be interpreted as a numeric value. Val stops reading the string at the first character that it cannot recognize as part of a number. Val also strips blanks, tabs, and linefeeds from the argument string. Symbols and characters often considered part of a numeric value, such as the dollar sign and commas, are not recognized by Val as numeric. The Val function always returns a Double. If the result of the Val function is assigned to a variable, the Double returned by Val is forced into the datatype of the variable. 

Example

Val ( 237 and 54)        returns 237
Val ( 2 4 54 7)            returns 24547
Val (17 Main Road )     returns 17

VBA Code

Dim MyNumber
MyNumber = Val(2 4 57 Main Road)

This example uses the Val function to return the numbers contained in a string. Now the MyNumber variable would contain the value 2457.

SQL query

You can also use the Val function in a query.

SELECT Val([Address]) AS Expr1
FROM EmployeeAddressTable


If you'd like to see how it works, enter SQL statement and press Execute
 




Tags:

Add To: Add to dzone dzone | Digg this digg | Add to del.icio.us del.icio.us | Stumble it stumbleupon

  • Comments





Copyright © 2005-2014             www.WebCheatSheet.com All Rights Reserved.