totn Access Functions

MS Access: FileLen Function

This MSAccess tutorial explains how to use the Access FileLen function with syntax and examples.

Description

The Microsoft Access FileLen function returns the size of a file in bytes.

Syntax

The syntax for the FileLen function in MS Access is:

FileLen ( file_path )

Parameters or Arguments

file_path
The path to a file name that you wish to retrieve the size for.

Returns

The FileLen function returns a numeric value in bytes.

Applies To

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

  • Access 2019, Access 2016, Access 2013, Access 2010, Access 2007, Access 2003, Access XP, Access 2000

Example

Let's look at how to use the FileLen function in MS Access:

FileLen ("C:\instructions.doc")
Result: 55808

FileLen ("H:\Documents\Supplies.xls")
Result: 1254

Example in VBA Code

The FileLen function can be used in VBA code in Microsoft Access.

For example:

Dim LResult As Long

LResult = FileLen ("C:\instructions.doc")

In this example, the variable called LResult would now contain the size of the instructions.doc file in bytes.

Example in SQL/Queries

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

For example:

Microsoft Access

In this query, we have used the FileLen function as follows:

Expr1: FileLen("C:\instructions.doc")

This query will return the size of the instructions.doc file in bytes. The results will be displayed in a column called Expr1. You can replace Expr1 with a column name that is more meaningful.

For example:

FileInfo: FileLen("C:\instructions.doc")

The results would now be displayed in a column called FileInfo.