Go Back   Access World Forums > Microsoft Access Discussion > General

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-16-2012, 02:53 PM   #1
aussie
Newly Registered User
 
Join Date: May 2012
Posts: 47
Thanks: 14
Thanked 0 Times in 0 Posts
aussie is on a distinguished road
Trust Centre

Hi, I have created a database and saved it to c:\Database\filename, using the full access 2007 version. I have made c:\Database a Trusted Centre.

I then copied the database onto my thumb drive (I:\Database\filename) and made this a trusted cenre.

I then added the Runtime version of Microsoft Access onto another computer.

When I try to access the database on the new computer I am unable to open the database, because it won't allow me to run macros.

When I try and open Access on the new computer, it won't open because it needs to associate to a database, so I am unable to set trust centers on the new computer.
Any help out there???

aussie is offline   Reply With Quote
Old 06-17-2012, 11:51 AM   #2
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 28,400
Thanks: 15
Thanked 1,625 Times in 1,543 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: Trust Centre

This is a big hole with the Access runtime. If you don't have the full retail version of Access, there is no way to define trusted locations with Access. That leaves you to modify the registry manually or add code to your application to do it. If you add code to your app, you'll still need to trust it once so it can run the code that modifies the registry.

Call this procedure from the Open event of your startup form. It checks the registry to see if the current folder is already trusted. If it isn't then it is added. I don't remember where I got this code so I can't give thanks to its author.

The code won't solve all your problems because it doesn't trust the BE location which you may also need to do but at least it shows how to create registry keys.

Code:
Option Compare Database
Option Explicit

Public Function AddTrustedLocation()
On Error GoTo err_proc
'WARNING:  THIS CODE MODIFIES THE REGISTRY
'sets registry key for 'trusted location'

  Dim intLocns As Integer
  Dim i As Integer
  Dim intNotUsed As Integer
  Dim strLnKey As String
  Dim reg As Object
  Dim strPath As String
  Dim strTitle As String
  
  strTitle = "Add Trusted Location"
  Set reg = CreateObject("wscript.shell")
  strPath = CurrentProject.Path

  'Specify the registry trusted locations path for the version of Access used
  strLnKey = "HKEY_CURRENT_USER\Software\Microsoft\Office\" & Format(Application.Version, "##,##0.0") & _
             "\Access\Security\Trusted Locations\Location"

On Error GoTo err_proc0
  'find top of range of trusted locations references in registry
  For i = 999 To 0 Step -1
      reg.RegRead strLnKey & i & "\Path"
      GoTo chckRegPths        'Reg.RegRead successful, location exists > check for path in all locations 0 - i.
checknext:
  Next
  MsgBox "Unexpected Error - No Registry Locations found", vbExclamation
  GoTo exit_proc
  
  
chckRegPths:
'Check if Currentdb path already a trusted location
'reg.RegRead fails before intlocns = i then the registry location is unused and
'will be used for new trusted location if path not already in registy

On Error GoTo err_proc1:
  For intLocns = 1 To i
      reg.RegRead strLnKey & intLocns & "\Path"
      'If Path already in registry -> exit
      If InStr(1, reg.RegRead(strLnKey & intLocns & "\Path"), strPath) = 1 Then GoTo exit_proc
NextLocn:
  Next
  
  If intLocns = 999 Then
      MsgBox "Location count exceeded - unable to write trusted location to registry", vbInformation, strTitle
      GoTo exit_proc
  End If
  'if no unused location found then set new location for path
  If intNotUsed = 0 Then intNotUsed = i + 1
  
'Write Trusted Location regstry key to unused location in registry
On Error GoTo err_proc:
  strLnKey = strLnKey & intNotUsed & "\"
  reg.RegWrite strLnKey & "AllowSubfolders", 1, "REG_DWORD"
  reg.RegWrite strLnKey & "Date", Now(), "REG_SZ"
  reg.RegWrite strLnKey & "Description", Application.CurrentProject.Name, "REG_SZ"
  reg.RegWrite strLnKey & "Path", strPath & "\", "REG_SZ"
  
exit_proc:
  Set reg = Nothing
  Exit Function
  
err_proc0:
  Resume checknext
  
err_proc1:
  If intNotUsed = 0 Then intNotUsed = intLocns
  Resume NextLocn

err_proc:
  MsgBox Err.Description, , strTitle
  Resume exit_proc
  
End Function
__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Old 06-17-2012, 03:43 PM   #3
Galaxiom
Super Moderator
 
Join Date: Jan 2009
Location: NSW Australia
Posts: 11,771
Thanks: 118
Thanked 1,546 Times in 1,451 Posts
Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold
Re: Trust Centre

A far preferable solution is to digitally sign the code. Then it will work anywhere once the user trusts the author. On a domain the whole process can be made completely transparent by using Group Policy to install the certificate in user's accounts.

However this option is not available for accd* files in 2007 format. Only packages can be signed. I only distribute mde so it is not an issue for me. There is nothing new worth having in the 2007 format anyway.

I understand the ability to sign a database was reintroduced in the accd* formats in Access 2010.

Galaxiom is offline   Reply With Quote
Old 06-18-2012, 08:30 AM   #4
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 28,400
Thanks: 15
Thanked 1,625 Times in 1,543 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: Trust Centre

Signing the database doesn't work in all situations plus certificates are not free. There is an annual fee attached.

In one of the apps I have that is sold nationwide, I have an archive procedure that creates a new database and transfers data into it. If the directory where the database is created is not trusted, the user gets a prompt for every table as it's created - 28 in this case.
__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Old 06-18-2012, 03:42 PM   #5
Galaxiom
Super Moderator
 
Join Date: Jan 2009
Location: NSW Australia
Posts: 11,771
Thanks: 118
Thanked 1,546 Times in 1,451 Posts
Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold
Re: Trust Centre

You can make your own free certificate using certsvr on Windows Servers. Once the public key of this certificate is accepted by the user they will not be asked again about any of your certificates.

I recommend the signature because I see far too many people defeating the whole Trusted Locations setup by setting folders like My Documents as Trusted.

The table creation problem is an issue I have not considered.
Galaxiom is offline   Reply With Quote
Old 06-19-2012, 06:03 AM   #6
aussie
Newly Registered User
 
Join Date: May 2012
Posts: 47
Thanks: 14
Thanked 0 Times in 0 Posts
aussie is on a distinguished road
Re: Trust Centre

Thanks all for your input. Will try out your suggestions

aussie is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA not running-Trust settings already set julestrip Modules & VBA 12 08-05-2010 08:45 AM
Question Trust what location? AccessProgram General 1 12-18-2009 08:45 PM
Trust access to vb project davea300 Modules & VBA 2 06-24-2009 03:29 PM
Trust issue alorenzini Macros 14 10-24-2007 07:07 PM
Runtime Trust Jim Stanicki General 0 09-14-2007 06:45 AM




All times are GMT -8. The time now is 11:39 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World