totn Access Functions

MS Access: CurrentUser Function

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

Description

The CurrentUser function returns the name of the current Access user. In a secured database, this would be the name of the user who has logged in. If the database is unsecured, this function would return Admin (the default account) as the name of the user.

Syntax

The syntax for the CurrentUser function in MS Access is:

CurrentUser()

Parameters or Arguments

There are no parameters or arguments for the CurrentUser function.

Returns

The CurrentUser function returns a string value.

Applies To

The CurrentUser 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 in VBA Code

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

For example:

Dim LUser As String

LUser = CurrentUser()

In this example, the variable called LUser would now contain the name of the user currently logged into the Access database.

Example in SQL/Queries

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

For example:

Microsoft Access

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

Expr1: CurrentUser()

This query will return the name of the current Access user and display the results in a column called Expr1. You can replace Expr1 with a column name that is more meaningful.

For example:

User: CurrentUser()

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