Code Samples for Businesses, Schools & Developers

First Published 9 Sept 2025

When developers refer to compiling an Access database, it can have either of two possible meanings.
Depending on the meaning, there are two different ways of using code to check if a VBA project or Access app is compiled.


1. Check if a VBA Project is Compiled

A VBA project should be compiled after any code changes to ensure there are no compilation errors. This should also be done before distributing any Access app.
This check is done by clicking Debug | Compile in the Visual Basic Editor (VBE).

Debug | Compile
If there are any errors, the compiler will stop and highlight the problem so it can be fixed. When all compilation errors are fixed, the Debug | Compile menu item will be 'greyed out'

VBA Project Compiled
Most developers will also set their VBA projects to be automatically compiled on demand from the VBE Options dialog:

VBE Options
It is very easy to check if a project is compiled using VBA code using the boolean IsCompiled function

For example, type ?IsCompiled in the Immediate window and press enter. The response will be True or False

IsCompiled function
The function can also be used with any external database. For example:


Function IsExtProjectCompiled(strPath As String, Optional strPwd As String = "") As Boolean

Dim appAcc As Access.Application

On Error Resume Next

IsExtProjectCompiled = False

' Create a new, hidden Access instance
Set appAcc = New Access.Application
' appAcc.Visible = False

If strPwd <> "" Then
appAcc.OpenCurrentDatabase strPath, , strPwd
Else
appAcc.OpenCurrentDatabase strPath
End If

Debug.Print "" & vbCrLf & strPath

IsExtProjectCompiled = appAcc.isCompiled

' Check compilation status
If IsExtProjectCompiled Then
Debug.Print "Project is compiled"
Else
Debug.Print "Project is NOT compiled"
End If

' Clean up
appAcc.CloseCurrentDatabase
appAcc.Quit
Set appAcc = Nothing

End Function


The code can be run on any compatible Access file (.accdb, .accde, .accdr, .mdb, .mde) including those with app passwords or VBA passwords.
For .accde or .mde files, the bitness must match the curent Office bitness.

The code can also be run on a batch of files in turn. For example:


Sub TestCompiled()

Dim dblStart As Double, dblEnd As Double

Debug.Print "IsExtProjectCompiled" & vbCrLf & "====================="
dblStart = Timer

IsExtProjectCompiled "G:\MyFiles\ExampleDatabases\SecureYourDatabase (SYD)\SYD_v1.6_PwdIsladogs_x64.accde", "isladogs"

IsExtProjectCompiled "G:\MyFiles\UserDatabases\Dale Fye\CommandBars2VBAPwd_Ruby.accdb"

IsExtProjectCompiled "G:\MyFiles\ExampleDatabases\DatabaseAnalyzerPro\ExampleDBs\BlankDB.mdb"

IsExtProjectCompiled "C:\Programs\MendipDataSystems\DatabaseAnalyzerPro\AttentionSeek_v691_TEST_Db.accdb", "isladogs"

IsExtProjectCompiled "G:\MyFiles\UserDatabases\Andre Minhorst\amvCalendar_V2\amvCalendar_V2.accdb"

IsExtProjectCompiled "G:\MyFiles\ExampleDatabases\AFR\Archive\3.99\AFR_v399.accdb"

IsExtProjectCompiled "G:\MyFiles\ExampleDatabases\CurrencyExchangeTracker\CurrencyExchangeTracker64.accde"

IsExtProjectCompiled "G:\MyFiles\ExampleDatabases\CustomSplashForm\CSF_StartApp\v3\CSFStart.accdr"

dblEnd = Timer

Debug.Print vbCrLf & "Total time taken = " & Round(dblEnd - dblStart, 3) & " sec"

End Sub



Example output:

IsCompiled Results


2. Check if an Access app is Compiled

In this case, we are checking whether a database has been compiled to an ACCDE or MDE file. This is sometimes misleadingly referred to as creating an Access executable file.

Before this can conversion can be done, the VBA project MUST first be compiled. This means that all ACCDE & MDE files must have IsCompiled = True

To check whether an Access file has been converted, we can search for the property MDE = "T". The property is created and the value set to "T" when the conversion is done.
This property does not exist in ACCDB / MDB files and checking for its value will trigger error 3270 (property not found).

NOTE: Renaming an .accdb file to .accde does NOT create this property. It does not depend on the file extension.

We can check whether the current database is compiled with code similar to this:


Function IsCurrentDBCompiled() As Boolean

On Error GoTo Err_Handler:
IsCurrentDBCompiled = CurrentDb.Properties("MDE") = "T"

Debug.Print "IsCurrentDBCompiled = " & IsCurrentDBCompiled

Exit_Handler:
Exit Function

Err_Handler:
'err 3270 = property not found
If Err = 3270 Then Resume Next
Resume Exit_Handler
End Function


To check whether an external database has been converted to ACCDE or MDE, use code similar to this:


Public Function IsExtDatabaseCompiled(strPath As String, Optional strConnect As String = "") As Boolean

Dim ws As DAO.Workspace
Dim extDb As DAO.Database
Dim isCompiled As Boolean

On Error GoTo Err_Handler

Set ws = DBEngine.Workspaces(0)
'strConnect is the connection string including any password
If strConnect <> "" Then
Set extDb = ws.OpenDatabase(strPath, False, False, strConnect)
Else
Set extDb = ws.OpenDatabase(strPath)
End If

' The "MDE" property exists only in compiled databases (.mde/.accde)
On Error Resume Next
isCompiled = (extDb.Properties("MDE") = "T")
On Error GoTo 0

IsExtDatabaseCompiled = isCompiled

Exit_Handler:
If Not extDb Is Nothing Then extDb.Close
Set extDb = Nothing
Set ws = Nothing
Exit Function

Err_Handler:
' Handle file not found, permission issues, etc.
Debug.Print "Error: " & Err.Number & " - " & Err.Description
Resume Exit_Handler

End Function


Typical Usage:


Sub TestCompiledStatus()
Dim strPath As String, strConnect As String
strPath = "C:\Programs\MendipDataSystems\CurrencyExchangeTracker\CurrencyExchangeTracker64.accde"
strConnect = "MS Access;PWD=T@yz32Wq8r;"

If IsExtDatabaseCompiled(strPath, strConnect) Then
MsgBox strPath & vbCrLf & vbCrLf & "The external database IS compiled (.accde or .mde).", _
vbInformation, "Is External Database Compiled?"
Else
MsgBox strPath & vbCrLf & vbCrLf & "The external database is NOT compiled (.accdb).", _
vbInformation, "Is External Database Compiled?"
End If
End Sub



Example output:

Is Ext Database Compiled


Download:

Click to download an example database with all the above code: Check Compiled      (ACCDB - zipped)     Approx 0.4 MB



Feedback

Please use the contact form below to let me know whether you found this article interesting/useful or if you have any questions/comments.

Please also consider making a donation towards the costs of maintaining this website. Thank you



Colin Riddington           Mendip Data Systems                 Last Updated 9 Sept 2025



Return to Code Samples Page




Return to Top