Search code examples
ms-accessvbams-access-2013ms-access-2016

How to detect if your Microsoft Access application is compiled, i.e. running as an ACCDE


Does anyone have any VBA to detect if your Microsoft Access 2013/2016 application is running as an ACCDE, i.e. is compiled?

I would like my code to stop and break if an error happens and a) it's me running it (environ("username')) and if it's not an ACCDE.

Anyone have any suggestions?


Solution

  • Adapted from https://access-programmers.co.uk/forums/showthread.php?t=229474 and http://allenbrowne.com/ser-53.html

    Public Function IsACCDE() As Boolean
    
        ' Init
        IsACCDE = False
    
        ' This property exists only in compiled DBs (.mde, .accde)!
        ' Ignore error (and stay "False") if not.
        On Error Resume Next
        IsACCDE = (CurrentDb.Properties("MDE") = "T")
    
    End Function