I have a function tied to my main forms on open event that adds the current db path as a trusted location to avoid the macro warnings each time the db is opened:
No need to execute this code each time the main form opens. So I would like to check if the registry entry exists and is equal to the current db path. If so, then exit function.
Thanks for the look,
Tux
Code:
Function MakeTrustedLocation()
On Error GoTo ET
Dim strFile As String, strLocation As String, strKey As String, strSql As String, strMsg As String
strKey = "[HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\MyTrustedPath]"
strLocation = Application.CurrentProject.Path & "\"
strLocation = Replace(strLocation, "\", "\\")
strFile = "C:\TEMP\TrustMyApplication.reg"
Open strFile For Output As #1
Print #1, "Windows Registry Editor Version 5.00"
Print #1, ""
Print #1, strKey
Print #1, """Path""=""" & strLocation & """"
Print #1, """AllowSubfolders""=dword:00000001"
Close #1
Shell ("regedit /s " & strFile)
Kill (strFile)
Exit Function
ET:
strMsg = Err.Number & " - " & Err.Description
Debug.Print strMsg
End Function
Thanks for the look,
Tux
Comment