如何检测您的 Microsoft Access 应用程序是否已编译,即 运行 作为 ACCDE
How to detect if your Microsoft Access application is compiled, i.e. running as an ACCDE
有人 VBA 可以检测您的 Microsoft Access 2013/2016 应用程序是否 运行 作为 ACCDE,即是否已编译?
我希望我的代码在发生错误时停止并中断 a) 是我 运行 它 (environ("username')) 如果它不是 ACCDE。
有人有什么建议吗?
改编自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
我使用它,它是 Access 的一部分 VBA:
If IsCompiled = False Then
DoCmd.RunCommand (acCmdCompileAndSaveAllModules)
End If
我找不到任何始终给我正确答案的属性。然后我意识到这些方法都是我真正想知道的近似值。现在直接问是不是accde
Private Function InDevelopment() As Boolean
On Error Resume Next
InDevelopment = False
InDevelopment = (InStr(CurrentDb.Properties("Name"), "accde") = 0)
End Function
有人 VBA 可以检测您的 Microsoft Access 2013/2016 应用程序是否 运行 作为 ACCDE,即是否已编译?
我希望我的代码在发生错误时停止并中断 a) 是我 运行 它 (environ("username')) 如果它不是 ACCDE。
有人有什么建议吗?
改编自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
我使用它,它是 Access 的一部分 VBA:
If IsCompiled = False Then
DoCmd.RunCommand (acCmdCompileAndSaveAllModules)
End If
我找不到任何始终给我正确答案的属性。然后我意识到这些方法都是我真正想知道的近似值。现在直接问是不是accde
Private Function InDevelopment() As Boolean
On Error Resume Next
InDevelopment = False
InDevelopment = (InStr(CurrentDb.Properties("Name"), "accde") = 0)
End Function