How to resolve Trust issues? (1 Viewer)

apeters

Registered User.
Local time
Today, 19:02
Joined
Nov 21, 2008
Messages
24
Hello, when I launch a newly installed Access 2007 runtime database, a pop-up entitled 'Action Failed' is displayed indicating that AutoExec could not be executed due to Error Number 2950.

Error number 2950, according to http://support.microsoft.com/kb/931407, arises when the application is not trusted. It goes on to explain that I can enable the database for the current session by clicking 'Options' on the Message Bar. There is no Message Bar:(

As the developer of this database application, I have tried a number of ways to deploy it to another machine, and all have been thwarted by Trust issues. My latest attempt was to use the Package Solution Wizard described here: http://msdn.microsoft.com/en-us/library/office/bb501030(v=office.12).aspx, with the result described above.

I would be grateful for any help on how I can resolve the trust issue on the target machine. Please note that the reason I have deployed a runtime version of the database is because Microsoft Office is not installed on the target machine and therefore does not (as far as I know) have access to the Trust Centre.
 

rzw0wr

I will always be a newbie
Local time
Today, 14:02
Joined
Apr 1, 2012
Messages
489
I THINK, you have to go to
File/Options/Trust Center/Trust Center Settings/Trusted Locations.
Then add the new location there.


TrustCenter.PNG
 

apeters

Registered User.
Local time
Today, 19:02
Joined
Nov 21, 2008
Messages
24
Thank you for your reply. Unfortunately, once the pop-up error message, and a subsequent error message, have both been dismissed, the application simply closes, so there is no opportunity to use any menus.
 

rzw0wr

I will always be a newbie
Local time
Today, 14:02
Joined
Apr 1, 2012
Messages
489
I found that Auotexec did not work for me in RunTime.
Try changing the name and run it from a command button.

Dale
 

apeters

Registered User.
Local time
Today, 19:02
Joined
Nov 21, 2008
Messages
24
I found that Auotexec did not work for me in RunTime.
Try changing the name and run it from a command button.

Dale

Thanks Dale, that got me a bit further. Now I can open (some) forms and look at basic data. It would appear, however, that if a form attempts to execute any code which is outside of that form, then the application will simply close down with a bland "Runtime error" message. For example, the event handler for a button on the form can display a message box, but cannot call a function from another module. Go figure!
 

Solo712

Registered User.
Local time
Today, 14:02
Joined
Oct 19, 2012
Messages
828
Yes, I've already seen this, thank you. Long story short: doesn't work for me. I'll persist with trying to produce an application which works with the Package Solution Wizard for now.

You will need to add the trusted location to the registry from the outside of Access. (Actually, you will need to do that for each user of the app. that will log on the machine).

There is an excellent command line utility (actually 3 of them, one each for A2007/A2010/A2013) here, that will do the registry work for you.

Best,
Jiri
 

John.Woody

Registered User.
Local time
Today, 19:02
Joined
Sep 10, 2001
Messages
354
You can use a vba function to add a trusted location. Can't remember where I found this, but it works for me in 2010. After installing the package the first time I open the db I get a trust message, then run the function and it adds the location as trusted.

Code:
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

HTH
 

Solo712

Registered User.
Local time
Today, 14:02
Joined
Oct 19, 2012
Messages
828
You can use a vba function to add a trusted location. Can't remember where I found this, but it works for me in 2010. After installing the package the first time I open the db I get a trust message, then run the function and it adds the location as trusted.

Code:
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

HTH

John, are you using this function with runtime A2010 applications ?

Best,
Jiri
 

John.Woody

Registered User.
Local time
Today, 19:02
Joined
Sep 10, 2001
Messages
354
Yes, the runtime package gets installed including A2010, and my db, I have taken to installing in a folder directly off the C drive on Win7 PCs to get round limited folder permissions. The first time the db is started I get a msgbox re trusted issue, I continue to load the db, run code to attach to data db, then I go into my admin form and click a button which runs this code adding the current db folder as a trusted folder. Next time the db is started it goes straight in, no trust message...
 

apeters

Registered User.
Local time
Today, 19:02
Joined
Nov 21, 2008
Messages
24
You will need to add the trusted location to the registry from the outside of Access. (Actually, you will need to do that for each user of the app. that will log on the machine).

There is an excellent command line utility (actually 3 of them, one each for A2007/A2010/A2013) here, that will do the registry work for you.

Best,
Jiri

Thank you for this. Now that I've added a Trusted Location, my application opens without the initial 'Are you sure you want to trust this Publisher?' message.

As soon as my application tries to execute any code which the Microsoft Access Runtime deems 'suspicious', however, the program just bombs out with a bland error message. For example, if I open a form containing a textbox control which is populated from a public function (e.g. set the data source to '=myfunction(myparameter)', the application shuts down due to an 'execution error'.

I'm beginning to think that it's just not possible to run such an application from the MS Access runtime. Luckily I'm able to install MS Office on the target machine, but there must surely be another way?
 

Solo712

Registered User.
Local time
Today, 14:02
Joined
Oct 19, 2012
Messages
828
Thank you for this. Now that I've added a Trusted Location, my application opens without the initial 'Are you sure you want to trust this Publisher?' message.

As soon as my application tries to execute any code which the Microsoft Access Runtime deems 'suspicious', however, the program just bombs out with a bland error message. For example, if I open a form containing a textbox control which is populated from a public function (e.g. set the data source to '=myfunction(myparameter)', the application shuts down due to an 'execution error'.

I'm beginning to think that it's just not possible to run such an application from the MS Access runtime. Luckily I'm able to install MS Office on the target machine, but there must surely be another way?

Sorry, I can't comment on this further except to tell you that whatever other you may have, they are highly unlikely originating with the Trust location of your app.

Best,
Jiri
 

way2bord

Registered User.
Local time
Today, 11:02
Joined
Feb 8, 2013
Messages
177
Thank you for this. Now that I've added a Trusted Location, my application opens without the initial 'Are you sure you want to trust this Publisher?' message.

As soon as my application tries to execute any code which the Microsoft Access Runtime deems 'suspicious', however, the program just bombs out with a bland error message. For example, if I open a form containing a textbox control which is populated from a public function (e.g. set the data source to '=myfunction(myparameter)', the application shuts down due to an 'execution error'.

I'm beginning to think that it's just not possible to run such an application from the MS Access runtime. Luckily I'm able to install MS Office on the target machine, but there must surely be another way?

Do you get a warning message saying you can't run the code because it's "Suspicious" ? What error number is that? And is it the same error number as an "execution error" ?

It sounds to me like you may have compatibility issues beyond your Trust Center trouble.
 

apeters

Registered User.
Local time
Today, 19:02
Joined
Nov 21, 2008
Messages
24
Do you get a warning message saying you can't run the code because it's "Suspicious" ? What error number is that? And is it the same error number as an "execution error" ?

It sounds to me like you may have compatibility issues beyond your Trust Center trouble.

The error number was 2950 (which has been covered earlier in this thread). The 'execution error' message is the one I always get whenever an unhandled exception occurs in the Access Runtime environment.

The problem has gone away now that I've installed MS Office 2007 Professional on the target PC (feels like cracking a nut with a sledge-hammer, but it turns out to be the most cost-effective solution in this case). Interestingly, when I launched the application again after installing MS Office, an error message indicated that it couldn't find the referenced mscomct2.ocx. I fixed this, and the application runs correctly. I wonder if the missing ocx was causing the earlier problems, but I'm not about to uninstall MS Office just to satisfy my curiosity.

Anyway, you're probably right - maybe it wasn't just a trust centre issue.

A big Thank You to everyone who helped.
 

Users who are viewing this thread

Top Bottom