Security Warning with TransferDatabase in Access 2007 Trusted Location

S

Sky

I was making a quick and dirty VBA tool to copy some tables into a database,
but it raised some security questions.

I've cut it down to this code example, which simply copies a table from an
external database.

' This still gives a security warning even from a trusted location in Access
2007 SP1 with Nov 2008 hotfix.
Sub TestThis()
DoCmd.TransferDatabase acImport, "Microsoft Access", "Backup.Mdb",
acTable, "MyTable", "MyTable"
End Sub

The code is in a database that is in a trusted location, so it does not have
any warnings when opened. The "Backup.Mdb" is also in the same trusted
location. The above code simply copies a table from the Backup.Mdb. (If the
table already exists, a numeric suffix is added to the name to avoid
overwriting, but that is not the issue here.)

Why do I get a security warning? The warning comes on the line with
DoCmd.TransferDatabase.

Just in case, I made sure that the SandBoxMode is disabled in the registry,
both for Access 2003 Jet4 and for Access 2007. I'm not sure which entry is
used when Access 2007 opens an Access 2003-compatible .Mdb Jet4 database
file. I have tried setting SandBoxMode to 2, and even to 0, for both
locations at the same time:
Root: HKCU; SubKey: Software\Microsoft\Jet\4.0\Engines; ValueType: dword;
ValueName: SandboxMode; ValueData: 2
Root: HKCU; SubKey: Software\Microsoft\Office\12.0\Access Connectivity
Engine\Engines; ValueType: dword; ValueName: SandboxMode; ValueData: 2

Again, I have also put both databases in the same trusted location.

The only thing that skips the security warning is to enable all macros
globally, using:
Root: HKCU; Subkey: "Software\Microsoft\Office\12.0\Access\Security";
ValueType: dword; ValueName: "VBAWarnings"; ValueData: 1

Turning off warnings globally seems drastic for this. I thought that a
trusted location was supposed to solve this. Am I doing something wrong?

- Steve
 
S

Sky

Sky said:
I was making a quick and dirty VBA tool to copy some tables into a
database, but it raised some security questions.

I've cut it down to this code example, which simply copies a table from an
external database.

' This still gives a security warning even from a trusted location in
Access 2007 SP1 with Nov 2008 hotfix.
Sub TestThis()
DoCmd.TransferDatabase acImport, "Microsoft Access", "Backup.Mdb",
acTable, "MyTable", "MyTable"
End Sub

The code is in a database that is in a trusted location, so it does not
have any warnings when opened. The "Backup.Mdb" is also in the same
trusted location. The above code simply copies a table from the
Backup.Mdb. (If the table already exists, a numeric suffix is added to the
name to avoid overwriting, but that is not the issue here.)

Why do I get a security warning? The warning comes on the line with
DoCmd.TransferDatabase.

Ok, I finally resolved this. If you specify a full path for the source
database, then the Trusted Location seems to apply correctly. Apparently
DoCmd.TransferDatabase does not fully resolve the path before checking
trusted locations, if you use a relative path after setting CurDir().

- Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top