Access: Mid Function

In Access, the Mid function returns a string containing a specified number of characters from a string.

The syntax for the Mid function is:

Mid( (string, start [, length]) )

string String expression from which another string is created. This can be any string expression. If string contains Null, Null is returned.

start   Long expression that indicates the character position in string at which the part to be taken begins. If start is greater than the number of characters in string, Mid returns a zero-length string (“”).

length   Long expression that indicates the number of characters to return. If omitted or if there are fewer than length characters in the text (including the character at start), all characters from the start position to the end of the string are returned.


Mid ("WebCheatSheet",1,3 )              returns " Web" 
Mid ("access functions",8,4)               returns "func"
Mid ("access functions",8)                  returns "access functions"

VBA Code

Dim MyString 
MyString = "Mid Function"
ResultWord = Mid(MyString, 1, 3)

This example uses the Mid function to return a specified number of characters from a string. Now the ResultWord variable would contain the value “Mid”.

SQL query

You can also use the Mid function in a query.

SELECT Mid([ItemDesired],2,5) AS Expr1 
FROM Orders



Leave a Reply

Your email address will not be published.