Disable Security Warning (1 Viewer)

iglobalusa

Registered User.
Local time
Today, 01:31
Joined
Jul 12, 2008
Messages
30
When users of my Access application with VBA codes open it they get a warning message from Access:

Security Warning: Unsafe expressions are not blocked. Do you want to block unsafe expressions?

The only way I can disable this Access security warning is if have the users go to Tools>Macro>Security and change the security level to low. Is there a VBA code that I can use to disable this message when the user opens my application?

Thanks for the help!
 

iglobalusa

Registered User.
Local time
Today, 01:31
Joined
Jul 12, 2008
Messages
30
Thanks for the resourceful link.
 

jal

Registered User.
Local time
Today, 01:31
Joined
Mar 30, 2007
Messages
1,709
In case you have trouble with this, here is more information:

UDFs (User Defined Function) might not work if unsafe expressions are blocked. You can have the best of both worlds if you can get sandbox mode turned on. Sandbox mode permits UDFs AND blocks unsafe expressions. ("Unsafe expressions" do not refer to all dangerous VBA code, but only the use of dangerous VBA code in an EXPRESSION).


SANDBOX MODE

Most of this info came from:
http://www.vb123.com/Toolshed/04_docs/sandbox.htm

To enable sandbox mode in Access 2003, first install Jet 4.0 Service pack 8 (this is probably already installed, so perhaps move on). For windows XP, go here to get this installation:

http://www.microsoft.com/downloads/...c4-350e-4cd0-a12a-d7f70a153156&displaylang=en

If your XP service packs are up to date or nearly so, perhaps you already have this Jet 4.0 Service Pack installed.
- Jet Service Pack 8 will automatically change the sandbox mode registry value from 3 to 2. This puts you in sandbox mode. Or, you can manually change the registry setting, as follows (or you can use the another method shown below). If you are new to the registry, be especially careful. From the Start > Run line type RegEdit and then navigate to this registry setting:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\SandboxMode
In the right pane you might see
0x00000003
but you probably need value 2. To do this, right-click 'SandboxMode' and select "Modify", this will open a window displaying the current value, typically you'll see the one digit "3" so just overtype it with the one digit "2". If you see multiple digits, you're probably in the wrong window. Here is what the values mean, according to the above article:
Value.......Description
0...........Sandbox mode is disabled at all times.
1...........Sandbox mode for Access applications only.
2...........Sandbox mode is used for non-Access applications only.
3...........Sandbox mode is used at all time.
 
Last edited:

iglobalusa

Registered User.
Local time
Today, 01:31
Joined
Jul 12, 2008
Messages
30
Jal:

First of all, thank you very much for your detailed instructions.

I'm pretty confident that our Jet 4.0 has been upgraded to SP8 but is there a way to tell? Also, there are 160 users in our department and most of them would not be able to follow your instructions, let alone attempt to do so. I certainly would not want them to fool around with RegEdit and I would prefer not to apply these changes individually to 160 PCs.

Would VBA code be able to accomplish the changes you mentioned and can you show me how to code this in VBA?


Regards.
 

Banana

split with a cherry atop.
Local time
Today, 01:31
Joined
Sep 1, 2005
Messages
6,318
This is just off the top of my head, but you should be able to tell by going to About Microsoft Access dialog. I *think* the Jet version is displayed there along with Access version. Could be wrong, though.

If this is necessary step (haven't researched into this), I would just do a batch file to automate the process and ask user to click on a small file and throw it away.
 

jal

Registered User.
Local time
Today, 01:31
Joined
Mar 30, 2007
Messages
1,709
This is just off the top of my head, but you should be able to tell by going to About Microsoft Access dialog. I *think* the Jet version is displayed there along with Access version. Could be wrong, though.

If this is necessary step (haven't researched into this), I would just do a batch file to automate the process and ask user to click on a small file and throw it away.
Thanks, Banana, I started researching your suggestion and then added my findings to my notes. Here's what I added, hope it helps someone:

Finally, if you have a large number of computers, you may wish to circulate a RegEdit file for the users to click on (make it read-only). Read on.

HOW TO CREATE A REGEDIT FILE

WARNING: These notes result from my first-ever attempt to create a RegEdit file. I honestly don't know what I'm doing and keep in mind that changes to the registry can destroy your computer.
- I took a look at this article:
http://support.microsoft.com/kb/310516
-Apparently the easiest way to create a RegEdit file is to let the system create it for you. Open Regedit at Start > Run and navigate to the desired key. Right-click and choose Export and then save the key to your Desktop. Regedit saves it with .Reg extension because this is a backup technique - you can double-click .Reg files to write their values back to the registry. Next, make another copy of this file (this is the one you will edit) and change its extension to .Txt as to edit it in Notepad. You might want to delete any lines irrelevant to the particular key you wish to edit.
- Now that the file only pertains to the desired key, go ahead and change the value (in Notepad). Then change the extension back to .Reg. Now if you double-click this file, it will edit the registry with the new value.
- So I took a stab at it - if you copy the following contents (for Windows XP) into a textfile and rename it to .Reg extension and then double click it, it should change the value to the desired 2.
-Starts here:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines]
"SandBoxMode"=dword:00000002
- Now if you store the above contents in a table or a VBA string, you can dynamically, at runtime, output it to a textfile (with a .Reg extension) and then run the .Reg file dynamically using the Shell command, or you can run the .Reg file by using the following command in a batch file (.BAT file):
REGEDIT C:\myFile.REG
 
Last edited:

jal

Registered User.
Local time
Today, 01:31
Joined
Mar 30, 2007
Messages
1,709
Jal:

First of all, thank you very much for your detailed instructions.

I'm pretty confident that our Jet 4.0 has been upgraded to SP8 but is there a way to tell? Also, there are 160 users in our department and most of them would not be able to follow your instructions, let alone attempt to do so. I certainly would not want them to fool around with RegEdit and I would prefer not to apply these changes individually to 160 PCs.

Would VBA code be able to accomplish the changes you mentioned and can you show me how to code this in VBA?


Regards.
If you read my last post, you'll see that the contents of the .Reg file should probably be as follows (let me know if you need more help):

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines]
"SandBoxMode"=dword:00000002
 
Last edited:

jal

Registered User.
Local time
Today, 01:31
Joined
Mar 30, 2007
Messages
1,709
The editor on this forum keeps putting a space within the word "Engines" - can't seem to delete it.
 

jal

Registered User.
Local time
Today, 01:31
Joined
Mar 30, 2007
Messages
1,709
Banana, do you know a way for a network administrator to update the registry for all the computers at once?
 

boblarson

Smeghead
Local time
Today, 01:31
Joined
Jan 12, 2001
Messages
32,059
The editor on this forum keeps putting a space within the word "Engines" - can't seem to delete it.

Yeah, that's a little quirk about this software. If you don't want it to do so, put things in between code tags (that will guarantee you no extra spaces)
 

jal

Registered User.
Local time
Today, 01:31
Joined
Mar 30, 2007
Messages
1,709
Maybe I'll try to write out a VBA module to handle this whole sandbox thing - I may find some use for this myself.
 

jal

Registered User.
Local time
Today, 01:31
Joined
Mar 30, 2007
Messages
1,709
Ok, here's my results. This should be convenient in that it runs invisibly (never asks the user for a confirmation). First, it checks to see whether the registry value is already set. If not, it sets the value.

Code:
Private Sub setSandBoxMode()
    Dim strFile As String, Quote As String, strMainValue As String, currentKey As String, line As String
    Quote = """"
    'We'll be looking for a value of 2
    strMainValue = Quote & "SandBoxMode" & Quote & "=dword:00000002"
    strFile = "C:\Sandbox.Reg"
    'Export the current registry value to the above file:
    Shell "REGEDIT.EXE  /E " & strFile & Space(1) & Quote & "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines" & Quote
    'Read the file to see if sandbox mode is already set correctly:
    Open strFile For Input As #1
    Dim found As Boolean
    Do While Not EOF(1)
        Line Input #1, line
        If InStr(line, strMainValue) > 0 Then found = True
    Loop
    Close #1
    If Not found Then 'registry value is not yet set
        Open strFile For Output As #1
        Print #1, "Windows Registry Editor Version 5.00"
        Print #1, ""  'blank line
        Print #1, "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines]"
        Print #1, strMainValue
        Close #1
        'The S-Switch means silent mode so the user doesn't have to click OK.
        Shell "Regedit.Exe /S " & strFile
    End If
    Kill (strFile)
End Sub
 
Last edited:

jal

Registered User.
Local time
Today, 01:31
Joined
Mar 30, 2007
Messages
1,709
Yeah, that's a little quirk about this software. If you don't want it to do so, put things in between code tags (that will guarantee you no extra spaces)

Thanks Bob, I'll keep that in mind.
 

Users who are viewing this thread

Top Bottom