Home page   WebCheatSheet.com


Access: Space Function


In Access, the Space function returns a string consisting of the specified number of spaces.

The syntax for the Space function is:

Space( number )

The argument number specifies the number of spaces you want in the string. It can be of any numeric data type, but is rounded to a Long and must be between 0 and approximately 65,535, inclusive.

Example

Space(2)    returns "  "
Space(7)    returns "       "

VBA Code

Dim MyStr, MyString
MyString = Space(3)

' Insert 5 spaces between two strings.
MyStr = "Test" & Space(5) & "string"

This example uses the Space function to return a string consisting of a specified number of spaces. Now the MyString variable would contain the value " ", and the MyStr variable would contain the value "test string"

SQL query

You can also use the Asc function in a query.

SELECT Space(5) AS Expr1
FROM Orders


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



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