totn Access Functions

MS Access: Or Function

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

Description

The Microsoft Access Or function returns TRUE if any of the conditions are TRUE. Otherwise, it returns FALSE.

Syntax

The syntax for the Or function in MS Access is:

condition1 Or condition2 [... Or condition_n] )

Parameters or Arguments

condition1, condition2, ... condition_n
Expressions that you want to test that can either be TRUE or FALSE.

Returns

The Or function returns TRUE if any of the conditions are TRUE.
The Or function returns FALSE if all conditions are FALSE.

Applies To

The Or 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 Or function with this syntax can only be used in VBA code in Microsoft Access.

Let's look at an example that combines the OR function with the If Statement in VBA:

If LWebsite = "TechOnTheNet.com" Or LCount > 50 Then
   LResult = "Normal"
Else
   LResult = "Low"
End If

This would set the LResult variable to the string value "Normal" if either LWebsite was "TechOnTheNet.com" or LCount > 50. Otherwise, it would set the LResult variable to the string value "Low".

You can use the OR function with the And function in VBA.

For example:

If (LWebsite = "TechOnTheNet.com" Or LWebsite = "CheckYourMath.com") And LTotal <= 90 Then
   LAudit = 1
Else
   LAudit = 2
End If

This would set the LAudit variable to the value 1 if LWebsite was either "TechOnTheNet.com" or "CheckYourMath.com" and LTotal <= 90. Otherwise, it would set the LAudit variable to the value 2.